473,550 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 InvalidCastExce ption when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activato r.CreateInstanc e
(fullAssemblyNa me, 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 2035
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
InvalidCastExce ption. 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*******@disc ussions.microso ft.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 InvalidCastExce ption when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activato r.CreateInstanc e
(fullAssemblyNa me, 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 theInvalidCastExc eption. 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*******@disc ussions.microso ft.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 InvalidCastExce ption when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activato r.CreateInstanc e
(fullAssemblyNa me, 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
InvalidCastEx ception. 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*******@disc ussions.microso ft.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 InvalidCastExce ption when
calling the unwrap method. Example code is shown below:

ObjectHandle obj = System.Activato r.CreateInstanc e
(fullAssemblyNa me, 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
3309
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 extensions). Now I want to install extension packages for Python 2.3; if the package is distributed via Distutils, this is no problem: 'python2.3...
2
1502
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 into memory? All 3 doing GCing and jit-ing and negotiating for available memory? I'm assuming yes, since VS7 can't be used with 1.1. Thanks,
3
1514
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 which one should it be - which one has the most common elements to all the versions?
2
1518
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 to a table from 2k to 97 it took it. So I'm thinking that if I have Frontends configured for different access versions and 1 backend I might be able...
3
1234
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 .net framework version which has language beside english try to execute my program. So how can i be able to compile my program for both languages ...
1
1351
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 that is using assembly B - B exists in different versions. Now I want to make it possible for A to ask B what features it supports or what data it can...
2
1103
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 used in a WinForm app that will still be using 1.1 so they can't be updated to the newer version at this point. How can I set my application to...
1
1444
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 2.0 app. Virtual directory /folder_a/folder_b, is configured as an application running .NET Framework 1.1 and contains an ASP.NET 1.1 app. When...
3
1642
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. Can anyone tell me what versions the command should work on and if there is a equivalent command for the other versions? cheers...
0
7561
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7488
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7845
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5403
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5129
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3532
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1978
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1094
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
801
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.