How to configure an assembly using CodeBase ...?

R

Raj

I am developing an application ... and it has reference to old version of the
assembly. Without recompiling the application how can I make reference to the
latest assembly using codebase? Old version of the assembly is in the local
GAC where the application is running and the latest version of the assembly
is on a remote server. I am using .NET Framework V 2.0 with Visual Studio
Express Edition for C#.

Old version of the assembly is 1.0.0.0 and the new version is 2.0.0.0

Thank you

Regards
Raj
 
P

Peter Duniho

I am developing an application ... and it has reference to old version
of the
assembly. Without recompiling the application how can I make reference
to the
latest assembly using codebase? Old version of the assembly is in the
local
GAC where the application is running and the latest version of the
assembly
is on a remote server. I am using .NET Framework V 2.0 with Visual Studio
Express Edition for C#.

Old version of the assembly is 1.0.0.0 and the new version is 2.0.0.0

What do you mean by "CodeBase"? Are you referring to the
System.Reflection.Assembly.CodeBase property? Or something else? In
either case, in what way do you specifically want to use it?

As for the more general question about using a new assembly with old code,
unless the old code was compiled with the reference to the assembly as
"require specific version", it should be fine to simply copy the new
assembly over, replacing the old one. Then the program should
automatically use the new assembly.

That's the default case. There are a number of things that might
interfere with that, but without more specific information, I don't see
any way to provide a better answer than "normally, it would 'just work'".

Pete
 
R

Raj

Pete,

Since the new assembly is on remote server, I could not move it to local GAC

I am trying out with .NET Framework 2.0 Configuration Tool (Start->Control
Panel->Administrative Tools->.NET Framework 2.0 Configuraion)
 
A

Alberto Poblacion

Raj said:
I am developing an application ... and it has reference to old version of
the
assembly. Without recompiling the application how can I make reference to
the
latest assembly using codebase? Old version of the assembly is in the
local
GAC where the application is running and the latest version of the
assembly
is on a remote server. I am using .NET Framework V 2.0 with Visual Studio
Express Edition for C#.

Old version of the assembly is 1.0.0.0 and the new version is 2.0.0.0

You can add a configuration file (myprogram.exe.config), and inside the
config file you will need to specify a couple of settings:
- Add a BindingRedirect to specify that version 1.0.0.0 needs to be
replaced by version 2.0.0.0.
- Add a CodeBase specifying the path to the 2.0.0.0 version.

The specific structure of the .config file can be found in the
documentation, but you don't need to know it. You can use the .Net Framework
Configuration Tool to specify the BindingRedirect and the CodeBase, and it
will write for you an appropriate .config file.

You will pobably need to adjust the CAS permissions (which can also be
done with the .Net Framework Configuration Tool), since the DLL loaded from
the server will default to permissions that are much more restrictive than
those of the DLL that you had in the GAC.
 
P

Peter Duniho

Pete,

Since the new assembly is on remote server, I could not move it to local
GAC

Sorry, maybe I'm missing something, but...why not? What stops you from
copying the assembly from the remote server and then using gacutil.exe to
install it in the local GAC?
I am trying out with .NET Framework 2.0 Configuration Tool
(Start->Control
Panel->Administrative Tools->.NET Framework 2.0 Configuraion)

I would expect that the information Alberto provided should do the trick.
But I'm still curious why there is (apparently) a need to reference the
assembly as it exists remotely, rather than copying it locally.

Pete
 
R

Raj

Albert

We are not supposed to hard code to bind to the codebase assembly.

Infact, I did try configuring the assembly by giving requested version
number and new version number, codebase etc., it is still not working ...
pointing to the same old version

FYI: When I paste the codebase URL I am able to download the assembly from
remote server.

Should the new version be 2.0.0.0 or 1.0.0.0? I tried various combinations
no respite!

Any help would be appreciated and I will remember you ever!
 
K

kndg

Raj said:
Albert

We are not supposed to hard code to bind to the codebase assembly.

Infact, I did try configuring the assembly by giving requested version
number and new version number, codebase etc., it is still not working ...
pointing to the same old version

FYI: When I paste the codebase URL I am able to download the assembly from
remote server.

Should the new version be 2.0.0.0 or 1.0.0.0? I tried various combinations
no respite!

Any help would be appreciated and I will remember you ever!

Hi Raj,

Try this,

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyAssembly"
publicKeyToken="17a77baefca73744" culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
<codeBase version="2.0.0.0"
href="http://remote_server/MyAssembly.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

- change "MyAssembly" to your assembly name
- change "publicKeyToken" to your assembly public key token
- "href" should point to the new assembly

Regards.
 
R

Raj

Dear kndg,

Thanks indeed for the great wok! patience!! and for your precious time!!!

:)

Regards
Raj
 
K

kndg

Raj said:
But how to do the same through the configuration tool?

I'm sorry, I don't have the configuration tool for .Net 2.0 installed.
However, I do have the configuration tool for .Net 1.1, so if the tool
layout is same, you may try below steps.

1. Click the Applications node and click "Add an Application to Configure"
2. Browse to your application
3. On the Configured Assemblies node, Click "Configure an Assembly"
4. Choose your assembly (the one that is installed in GAC) and then
click "Finish"
5. On Binding Policy tab, set the Requested Version to 1.0.0.0 and New
Version to 2.0.0.0
6. On Codebases tab, set Requested Version to 2.0.0.0 and URI to the
location of the new assembly
7. Click OK

Regards.
 
R

Raj

Its workin!

Thanx a lot

What's your name&mail id ... I want to add you to my contacts list

Thank you

Regards
Raj
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top