
Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Hi,
No, the type is not defined in another assembly, nor is there any other cached assemblies lying around.
This is the code that fails:
The type SecSoaService.NFFIServiceParameters inherits from the abstract class ServiceParameters.
public ServiceParameters EditWebServiceParameters(ServiceParameters parameters)
{
SecSoaService.NFFIServiceParameters param = null;
try
{
param = (SecSoaService.NFFIServiceParameters)parameters; //exception is thrown.
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
// test
try
{
param = (SecSoaService.NFFIServiceParameters)(new SecSoaService.NFFIServiceParameters()); //no exception.
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
...
}
From the watch window i extract the following:
parameters.GetType().Module.FullyQualifiedName = "c:\\temp\\IFM\\Tool\\modules\\services\\secsoa\\SecSoaService.dll" string
and the
parameters.GetType().AssemblyQualifiedName = "SecSoaService.NFFIServiceParameters, SecSoaService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e9c77c3cc6a7a0ac"
And the param variable gets the following values after beeing assigned:
param.GetType().Module.FullyQualifiedName = "C:/temp/IFM/Tool/modules/services/secsoa\\SecSoaService.dll" string
param.GetType().AssemblyQualifiedName = "SecSoaService.NFFIServiceParameters, SecSoaService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e9c77c3cc6a7a0ac"
As you can see both types have the same Assembly Qualified name and the same Module FullyQualifiedName.
So as far as i can see these two types are identical!
The only thing that is different is the format of the FullyQualifiedName path.
regards,
Lars
>> I get a InvalidCastException:
>> - ex {"Unable to cast object of type 'SecSoaService.NFFIServiceParameters'
[quoted text clipped - 3 lines]
> Does that type exist in multiple assemblies? If so, that's probably the
> issue.
Jon Skeet [C# MVP] - 31 May 2006 07:55 GMT
> No, the type is not defined in another assembly, nor is there any other cached assemblies lying around.
It looks like they're loaded into different Assembly instances though,
given the fully qualified name differences. (Even if everything was the
same, being in different Assembly instances would be a problem.)
Are either of these assemblies loaded explicitly using Assembly.Load?

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Lars - 31 May 2006 11:14 GMT
You nailed the problem :)
I changed from LoadFile to LoadFrom to enforce same context.
Thanks alot,
Lars
>> No, the type is not defined in another assembly, nor is there any other
>> cached assemblies lying around.
[quoted text clipped - 4 lines]
>
> Are either of these assemblies loaded explicitly using Assembly.Load?