I've been searching on this exception, and one thing they suggest is
that if the same assembly is loaded from 2 different locations, that can
cause grief - and indeed it is.

When Outlook opens, it seems to load the addin from C:\Documents and
Settings\deanc\Local Settings\Application
Data\assembly\dl3\KDBRMV9Y.9BV\X4AEVA3M.YJY\53b145d6\294be7c3_1ee8c601\,
but the COM control loads from a different location.

Anyone know the reason for the load from Local Settings? Is that a VSTO
design time trick, or is it going to do that on clients anyway (which
probably means I will never be able to remote from the Addin/COM control
combination).

Dino

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Dean Cleaver
Sent: Saturday, 14 October 2006 13:55
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Get an AppDomain you didn't create

Mike,

I get an InvalidCastException:

System.InvalidCastException: Return argument has an invalid type.
   at System.Runtime.Remoting.Proxies.RealProxy.ValidateReturnArg(Object
arg, Type paramType)
   at
System.Runtime.Remoting.Proxies.RealProxy.PropagateOutParameters(IMessag
e msg, Object[] outArgs, Object returnValue)
   at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
   at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
   at Xception.Midas.DataAccess.Generated.ClassFactory.NewInstance()
   at Xception.Midas.DataAccess.Generated.ClassFactory.CreateInstance()
in C:\Documents and Settings\deanc\My Documents\Visual Studio
2005\Projects\Xception\Midas\DataAccess\Generated\ClassFactory.cs:line
1311

But I don't get that error from the first AppDomain.

There is a possibility that the files are loading from 2 different
locations (the Outlook Addin loads from the Addin project Release
folder, whereas the COM control loads from the UI projects Release
folder - if that makes a difference?). They are both compiled in the
same solution though.

Dino

-----Original Message-----
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Woodring
Sent: Saturday, 14 October 2006 13:08
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Get an AppDomain you didn't create

> I have code in 2 AppDomains that need to call the same code on the 
> same remote server. The actual code in each AppDomain is identical (2 
> copies of the same assemblies) however the second one always fails. I 
> have found some references from other people indicating this is a 
> known issue, but it's hard to find because 99% of references to 2 
> AppDomains pertain to calling between them, not both calling the same
server.
>
> .Net 2.0

That's odd, because it works for me.  Before I posted the code I did,
I'd scratched out a simple app that setup 2 appdomains, both of which
connected to the same remote server.  Then I read the email trail a bit
closer and got the impression you were just trying to talk from one app
domain to another.

I'm not near that code at the moment, but if you email me offlist I can
send it your way.  Alternatively, maybe include the actual exception
details you're seeing?

-Mike
http://www.bearcanyon.com
http://www.pluralsight.com/mike

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to