471,337 Members | 907 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

Allow to reference to any version of assembly during compiling

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(compilerParamet ers, 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(compilerParamet ers, code);
}
Oct 15 '07 #1
6 14793
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(compilerParamet ers, 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(compilerParamet ers, 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#)
------------------------------------------------------------------------
Oct 16 '07 #2
Frans,
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.
thank you.

The file mydll.dll which I reference is produced by external vendor.
I have no control over its versioning or signing.

So I must reference to any version of this file from my dynamically created
assembly.

Anyh idea how to implement this ?

Andrus.
Oct 16 '07 #3
Andrus wrote:
Frans,
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.

thank you.

The file mydll.dll which I reference is produced by external vendor.
I have no control over its versioning or signing.

So I must reference to any version of this file from my dynamically
created assembly.

Anyh idea how to implement this ?
This vendor, don't they ship a policy file with thier assembly?

Is the mydll signed (does it have a strong name?)

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#)
------------------------------------------------------------------------
Oct 17 '07 #4
>The file mydll.dll which I reference is produced by external vendor.
>I have no control over its versioning or signing.

So I must reference to any version of this file from my dynamically
created assembly.

Anyh idea how to implement this ?

This vendor, don't they ship a policy file with thier assembly?
I have the following files (mydll is actually Castle.ActiveRecord) :

14.10.2007 16:55 192 512 Castle.ActiveRecord.dll
14.10.2007 16:55 658 944 Castle.ActiveRecord.pdb
14.10.2007 16:55 459 779 Castle.ActiveRecord.xml

So I think I don't have policy file (I have no idea what is policy file)
Is the mydll signed (does it have a strong name?)
Solution explorer shows the following properties for Castle.ActiveRecord.dll

Strong Name true
Version 1.0.3.0

So it is signed.

Andrus.
Oct 17 '07 #5
Andrus wrote:
The file mydll.dll which I reference is produced by external
vendor. I have no control over its versioning or signing.
>
So I must reference to any version of this file from my
dynamically created assembly.
>
Anyh idea how to implement this ?
This vendor, don't they ship a policy file with thier assembly?

I have the following files (mydll is actually Castle.ActiveRecord) :

14.10.2007 16:55 192 512 Castle.ActiveRecord.dll
14.10.2007 16:55 658 944 Castle.ActiveRecord.pdb
14.10.2007 16:55 459 779 Castle.ActiveRecord.xml

So I think I don't have policy file (I have no idea what is policy
file)
Is the mydll signed (does it have a strong name?)

Solution explorer shows the following properties for
Castle.ActiveRecord.dll

Strong Name true
Version 1.0.3.0

So it is signed.
But if you reference that dll in YOUR application, every build of your
application shoudl be able to load that particular dll with that
particular version.

If you then place 1.0.4.0 in the bin folder, you won't be able to load
that file. But, if you add an assembly redirect in your application's
config file to redirect bindings to 1.0.3.0 to 1.0.4.0, you will be
able to load that file. Of course, if 1.0.4.0 has newer interfaces and
breaking changes, it's not wise to do so, but you can.

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#)
------------------------------------------------------------------------
Oct 18 '07 #6
But if you reference that dll in YOUR application, every build of your
application shoudl be able to load that particular dll with that
particular version.
Yes, I can rebuild my solution and this works OK.
However the issue occurs in customer sites when I upgrade referenced dll
file but my dynamically generated assembly contains reference to old
version.
If you then place 1.0.4.0 in the bin folder, you won't be able to load
that file. But, if you add an assembly redirect in your application's
config file to redirect bindings to 1.0.3.0 to 1.0.4.0, you will be
able to load that file. Of course, if 1.0.4.0 has newer interfaces and
breaking changes, it's not wise to do so, but you can.
As I understand at application startup I need to check assembly version and
dynamically update app.config file by adding assembly redirect.

Vista UAC prevents my application changing app.config file.
How to create dynamic assembly redirect without writing to restricted
directories ?
Or is there better solution ?

Andrus.
Oct 18 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rui Macdonald | last post: by
4 posts views Thread by dhnriverside | last post: by
16 posts views Thread by Kent | last post: by
5 posts views Thread by John A Grandy | last post: by
reply views Thread by =?Utf-8?B?SmFtZXM=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.