473,499 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 15040
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
346
by: Rui Macdonald | last post by:
I working with some samples from angGoGo PhotoControl and when I start it I receive always the following message, can you help me please? :-( -------------------- The located assembly's manifest...
4
1856
by: dhnriverside | last post by:
HI guys I've just written my first independent namespace for my library (yay me!). However, on trying to add it to my website project, it causes an error when I look at the website. It compiles...
16
2062
by: Kent | last post by:
We have created several Assemblies that we add to the GAC on our web servers. In an ASP.NET app in VS2003, Adding a reference to strong named GAC'd Assembly meant that the web app would use...
0
1463
by: stic | last post by:
Hi, After a few hours of asp. net configuration, ACL, web service specifications digging and of course extensive googling, I finally came to you… and as usually I need help… I need to...
5
4571
by: John A Grandy | last post by:
How to use the .NET Reflector to determine which .NET version and assembly was compiled in ?
0
1971
by: =?Utf-8?B?SmFtZXM=?= | last post by:
I'm stuck with the following error... Does anyone know how to correct the reference? I've not idea why it is referencing 'Copy of...' Server Error in '/Client1' Application....
7
10017
by: chage | last post by:
Hi, I have been searching around to try adding reference assembly to another assembly during runtime, programatically. Is this possible in .Net? The reason for this is because i am having...
0
1361
by: JB | last post by:
I have an ASP project written years ago that I have recently started to try and update. It was written by someone who used to work here before me, and the source code I have is in a major mess. ...
2
5125
by: Febria | last post by:
Dear, all... I have some problem with my application. I used UltraWebGrid component in my web application. Unfortunately, when I tried to run the web, the error page displayed: The located...
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.