Hi,
No, the type is not defined in another assembly, nor is there any other =
cached assemblies lying around. =20
This is the code that fails:
The type SecSoaService.NFFIServiceParameters inherits from the abstract =
class ServiceParameters.
public ServiceParameters EditWebServiceParameters(ServiceParameters =
parameters)
{
SecSoaService.NFFIServiceParameters param =3D null;
try
{
param =3D (SecSoaService.NFFIServiceParameters)parameters; =
//exception is thrown.
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
// test =20
try =20
{
param =3D (SecSoaService.NFFIServiceParameters)(new =
SecSoaService.NFFIServiceParameters()); //no exception.
}
catch (Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.Message);
}
...
}=20
From the watch window i extract the following:
parameters.GetType().Module.FullyQualifiedName =3D =
"c:\\temp\\IFM\\Tool\\modules\\services\\secsoa\\SecSoaService.dll" =
string
and the=20
parameters.GetType().AssemblyQualifiedName =3D =
"SecSoaService.NFFIServiceParameters, SecSoaService, Version=3D1.0.0.0, =
Culture=3Dneutral, PublicKeyToken=3De9c77c3cc6a7a0ac"
And the param variable gets the following values after beeing assigned:
param.GetType().Module.FullyQualifiedName =3D =
"C:/temp/IFM/Tool/modules/services/secsoa\\SecSoaService.dll" string
param.GetType().AssemblyQualifiedName =3D =
"SecSoaService.NFFIServiceParameters, SecSoaService, Version=3D1.0.0.0, =
Culture=3Dneutral, PublicKeyToken=3De9c77c3cc6a7a0ac"=20
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. =20
regards,
Lars
=20
[quoted text, click to view] "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message =
news:MPG.1ee547792bfcd52498d1fc@msnews.microsoft.com...
> Lars <lars@nospam.com> wrote:
>> I get a InvalidCastException:
>> - ex {"Unable to cast object of type =
'SecSoaService.NFFIServiceParameters'=20
>> to type 'SecSoaService.NFFIServiceParameters'."} System.Exception=20
>> {System.InvalidCastException}
>=20
> Does that type exist in multiple assemblies? If so, that's probably =
the=20
> issue.
>=20
> --=20
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet