473,394 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Calling assemblies compiled in different framework versions

I have a service which is used to call differenct versions
of an application depending on the database version that
is being used.

The service has been compiled in framework 1.1 and it
needs to call the current version of the application (also
compiled in framework 1.1) and also historic versions
(compiled in framework 1.0).

The application compiled in framework 1.1 loads correctly,
however, when it attempts to load the assemblies compiled
in framework 1.0 I get an InvalidCastException when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activator.CreateInstance
(fullAssemblyName, pc.Type);
IInstance m_instance = (IInstance)obj.Unwrap();

The DLL highlighted by the thrown exception is stored in
the GAC. And a different assembly version applies to each
instance. I have a application config file but it doesn't
appear to have had an effect.

Any Ideas?

Nov 15 '05 #1
4 2022
Where is IInstance defined? If the IInstance in your service is not the
same IInstance that is implemented in the other assembly then you'll get the
InvalidCastException. Remember that a type with the same name in 2
different assemblies is considered 2 different types.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
"Richard" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
I have a service which is used to call differenct versions
of an application depending on the database version that
is being used.

The service has been compiled in framework 1.1 and it
needs to call the current version of the application (also
compiled in framework 1.1) and also historic versions
(compiled in framework 1.0).

The application compiled in framework 1.1 loads correctly,
however, when it attempts to load the assemblies compiled
in framework 1.0 I get an InvalidCastException when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activator.CreateInstance
(fullAssemblyName, pc.Type);
IInstance m_instance = (IInstance)obj.Unwrap();

The DLL highlighted by the thrown exception is stored in
the GAC. And a different assembly version applies to each
instance. I have a application config file but it doesn't
appear to have had an effect.

Any Ideas?

Nov 15 '05 #2
Thanks

Am I correct in assuming that the only way around this is
to recompile the application with references to the same
interface?

Richard
-----Original Message-----
Where is IInstance defined? If the IInstance in your service is not thesame IInstance that is implemented in the other assembly then you'll get theInvalidCastException. Remember that a type with the same name in 2different assemblies is considered 2 different types.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.

"Richard" <an*******@discussions.microsoft.com> wrote in messagenews:0c****************************@phx.gbl...
I have a service which is used to call differenct versions of an application depending on the database version that
is being used.

The service has been compiled in framework 1.1 and it
needs to call the current version of the application (also compiled in framework 1.1) and also historic versions
(compiled in framework 1.0).

The application compiled in framework 1.1 loads correctly, however, when it attempts to load the assemblies compiled in framework 1.0 I get an InvalidCastException when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activator.CreateInstance
(fullAssemblyName, pc.Type);
IInstance m_instance = (IInstance)obj.Unwrap();

The DLL highlighted by the thrown exception is stored in
the GAC. And a different assembly version applies to each instance. I have a application config file but it doesn't appear to have had an effect.

Any Ideas?

.

Nov 15 '05 #3
And shouldn't an application config file be able to help?
-----Original Message-----
Thanks

Am I correct in assuming that the only way around this is
to recompile the application with references to the same
interface?

Richard
-----Original Message-----
Where is IInstance defined? If the IInstance in yourservice is not the
same IInstance that is implemented in the other assembly

then you'll get the
InvalidCastException. Remember that a type with the samename in 2
different assemblies is considered 2 different types.

--
--Grant
This posting is provided "AS IS" with no warranties, and

confers no rights.


"Richard" <an*******@discussions.microsoft.com> wrote in

message
news:0c****************************@phx.gbl...
I have a service which is used to call differenct

versions of an application depending on the database version that is being used.

The service has been compiled in framework 1.1 and it
needs to call the current version of the application(also compiled in framework 1.1) and also historic versions
(compiled in framework 1.0).

The application compiled in framework 1.1 loadscorrectly, however, when it attempts to load the assembliescompiled in framework 1.0 I get an InvalidCastException when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activator.CreateInstance
(fullAssemblyName, pc.Type);
IInstance m_instance = (IInstance)obj.Unwrap();

The DLL highlighted by the thrown exception is stored in the GAC. And a different assembly version applies toeach instance. I have a application config file but itdoesn't appear to have had an effect.

Any Ideas?

.

.

Nov 15 '05 #4
Possibly a config file can help. It all depends on where IInstance is
defined. If IInstance is in the application, then you're stuck. If
IInstance is in the service, then you might be able to get it working
without recompiling.

If I were to design this from the ground-up, I would have 1 assembly/dll
that just has interfaces like IInstance that dictate how the application and
the service communicate. That assembly is now the 'lowest common
denominator'. Then the application and service both reference that assembly
when they build.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Logan | last post by:
I have two different Python versions on my Linux system (2.2 and 2.3). I cannot remove version 2.2 because many configuration files of the system depend on this version of Python (and its...
2
by: Roger | last post by:
Hi All, If a user runs a Framework 1.0 app, and then opens a 1.1 app, and then opens a 1.2 app (when version 1.2 comes) , does this mean that all three versions of the Framework will be loaded...
3
by: zorro | last post by:
Hello, If I have to test my code on different Netscape versions, can I download and run those versions on the same computer or will it create conflicts? And if I had to test only one version...
2
by: ken | last post by:
I may need to have front ends configured for Access 2002 and 2000 and have one access 2000 backend. I think it might work? Right now I have access 97 and 2k on my computer and when I tried linking...
3
by: Dakkar | last post by:
I wrote a program with english .net framework version but i want people who use turkish .net framework versions to be able to use my program but its giving the language error when somebody with a...
1
by: Tim Bücker | last post by:
Hello. Are there any resources out there (because I couldn´t find any) concerning the usage of assemblies with different features in each version? In other words: I´ve got one assembly A...
2
by: ieg999 | last post by:
I have an ASP.NET 2.0 application that uses mulitple assemblies. I need certain assemblies to use .NET 1.1. These are library (DLL) assemblies used in my application. These same DLLs are also...
1
by: jonas | last post by:
I have a problem with different .NET Framework versions in virtual directories. Virtual directory /folder_a, is configured as an application running ..NET Framework 2.0 and contains an ASP.NET...
3
by: paulsnz | last post by:
Hi I am trying to use the SoftwareAudit.exe command accross a number of Windows server platforms. they have various framework versions implemented and the command only works on some versions. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.