Re: Allow to reference to any version of assembly during compiling

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Andrus wrote:

VCSE 2005 .NET 2 WinForms

I created assembly at runtime and added mydll.dll reference to it.
mydll.dll is in applicatino startup directory.
When I change mydl.dll to never version, this assembly is not loaded
anymore: error occurs which says that created assembly requires
specific version of mydll.dll

How to add assembly reference at runtime which does not require
specific version ?

Andrus.

My code:

void CompileAssembly(string code, string assemblyName) {

CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");
CompilerParameters compilerParameters = new CompilerParameters();
CompilerResults result =
provider.CompileAssemblyFromSource(compilerParameters, code);
// this causes created assembly to require specific version of mydll
// How to allow to use any version on mydll.dll file ?
compilerParameters.ReferencedAssemblies.Add("mydll.dll");
compilerParameters.GenerateInMemory = false;
compilerParameters.OutputAssembly = assemblyName;
CompilerResults compilerResults =
provider.CompileAssemblyFromSource(compilerParameters, code);
}

Did you sign mydll.dll ? If so, be sure the assembly version attribute
contains a real version, so not 1.0.*.* (which changes with every
build!) but 1.0.0.0 and version only when you need to (i.e. when the
interface breaks), which means you have to re-compile the clients
anyway.

FB


--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
.



Relevant Pages

  • Allow to reference to any version of assembly during compiling
    ... I created assembly at runtime and added mydll.dll reference to it. ... mydll.dll is in applicatino startup directory. ... void CompileAssembly(string code, string assemblyName) { ... CompilerResults compilerResults = ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: invoke a webservice with nillable value types
    ... generate the assembly for your schema one time, ... service add a reference to the assembly we created above in XsdObjectGen. ... >It is supported to supress serialization of properties using the ... FindBDImplService failed with the error "File- or Assemblyname ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: SSIS An error occurred while attempting to perform a type cast
    ... 2005 Microsoft Corporation; All Rights Reserved; ... AssemblyName = "System.Data" ...
    (microsoft.public.sqlserver.dts)
  • Exception with Child AppDomain
    ... Web app with a reference to an external Assembly (it has no strong ... at System.Reflection.Assembly.nLoad(AssemblyName fileName, String ... at System.Activator.CreateInstance(String assemblyName, String ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: Type.GetType(string) question
    ... You also need to watch for the circular reference at the bottom;-p ... static Type WalkAssemblies(string name, AssemblyName an, IListskip) ... foreach(AssemblyName nextRef in a.GetReferencedAssemblies()) { ...
    (microsoft.public.dotnet.languages.csharp)