| | |
Return value failed in Invoke
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi all,
My problem is continue from this post:
http://social.msdn.microsoft.com/For...d-4c13d959e5f1
I created a Unit Test by NUnit to test the method which is stored in DLL. The method should return a complex type variable (an object instance, Company for example). When the calling side (in Unit Test module) cast the type from Object to Company, the simular error is thrown:
==========
Unit Test side:
==========
I started to understand what is binding context in assembly. This is the error message which thrown by casting task (can see it from NUnit working form):
word8.Plugin_test.CreateCompany_test:
System.InvalidCastException :
[A]word8.Xyz_Library.CompanyModule.Company cannot be cast to [B]word8.Xyz_Library.CompanyModule.Company.
Type A originates from 'Xyz_Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:\Development(5)\Projects\word8_net\word8\word8\bin\Debug\Plugins\Xyz_Library.dll'.
Type B originates from 'Xyz_Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Documents and Settings\Administrator\Local Settings\Temp\nunit20\ShadowCopyCache\3816_633640437807493750\Tests\assembly\dl3\e0402b93\6c49ad91_4456c901\Xyz_Library.DLL'.
I think becase the custom type Company are come from difference DLL. But, I still do not know how to get rid of it.
The project source is short like before, and place here: http://www.box.net/shared/1y7o6r5xtu
Or here: http://www.adrive.com/public/76d8dc4...fbfaa853e.html
Hope you can help me again. Thank you very much.
Best regards,
Diviner.
My problem is continue from this post:
http://social.msdn.microsoft.com/For...d-4c13d959e5f1
I created a Unit Test by NUnit to test the method which is stored in DLL. The method should return a complex type variable (an object instance, Company for example). When the calling side (in Unit Test module) cast the type from Object to Company, the simular error is thrown:
==========
Unit Test side:
==========
C# Syntax (Toggle Plain Text)
private Company CreateCompany(Client client) { PluginManager.Plugins.FindPlugins(@"C:\...\Plugins", null); Object Xyz_Plugin = PluginManager.Plugins.AvailablePlugins.Find("Xyz_Plugin").Instance; Object company = QuickReflection.Invoke(Xyz_Plugin, "CreateCompany", client); return (Company)company; // Error here... }
I started to understand what is binding context in assembly. This is the error message which thrown by casting task (can see it from NUnit working form):
word8.Plugin_test.CreateCompany_test:
System.InvalidCastException :
[A]word8.Xyz_Library.CompanyModule.Company cannot be cast to [B]word8.Xyz_Library.CompanyModule.Company.
Type A originates from 'Xyz_Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:\Development(5)\Projects\word8_net\word8\word8\bin\Debug\Plugins\Xyz_Library.dll'.
Type B originates from 'Xyz_Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Documents and Settings\Administrator\Local Settings\Temp\nunit20\ShadowCopyCache\3816_633640437807493750\Tests\assembly\dl3\e0402b93\6c49ad91_4456c901\Xyz_Library.DLL'.
I think becase the custom type Company are come from difference DLL. But, I still do not know how to get rid of it.
The project source is short like before, and place here: http://www.box.net/shared/1y7o6r5xtu
Or here: http://www.adrive.com/public/76d8dc4...fbfaa853e.html
Hope you can help me again. Thank you very much.
Best regards,
Diviner.
•
•
Join Date: Jul 2008
Posts: 66
Reputation:
Solved Threads: 6
hi divine
im also not sure plz
first let chk client s what datatype
passing parameter datatype and geting val datatype, the both datatype should be same.in my knowledge i think datatype s differ.makeit same then wil c ? s the probelm
im also not sure plz
•
•
•
•
Object plugin = PluginManager.Plugins.AvailablePlugins.Find("Xyz_Plugin").Instance;
return (Form)QuickReflection.MyInvoke(plugin, "CreateXyzForm", client);
public static Object MyInvoke(Object target, String method, params Object[] args)
{
MethodInfo methodInfo = target.GetType().GetMethod(method);
return methodInfo.Invoke(target, args);
}
The Called side (DLL party) like this:
public Form CreateXyzForm(Client client)
{
.....
}
passing parameter datatype and geting val datatype, the both datatype should be same.in my knowledge i think datatype s differ.makeit same then wil c ? s the probelm
•
•
•
•
Hi all,
My problem is continue from this post:
http://social.msdn.microsoft.com/For...d-4c13d959e5f1
I created a Unit Test by NUnit to test the method which is stored in DLL. The method should return a complex type variable (an object instance, Company for example). When the calling side (in Unit Test module) cast the type from Object to Company, the simular error is thrown:
==========
Unit Test side:
==========
C# Syntax (Toggle Plain Text)
private Company CreateCompany(Client client) { PluginManager.Plugins.FindPlugins(@"C:\...\Plugins", null); Object Xyz_Plugin = PluginManager.Plugins.AvailablePlugins.Find("Xyz_Plugin").Instance; Object company = QuickReflection.Invoke(Xyz_Plugin, "CreateCompany", client); return (Company)company; // Error here... }
I started to understand what is binding context in assembly. This is the error message which thrown by casting task (can see it from NUnit working form):
word8.Plugin_test.CreateCompany_test:
System.InvalidCastException :
[A]word8.Xyz_Library.CompanyModule.Company cannot be cast to [B]word8.Xyz_Library.CompanyModule.Company.
Type A originates from 'Xyz_Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:\Development(5)\Projects\word8_net\word8\word8\bin\Debug\Plugins\Xyz_Library.dll'.
Type B originates from 'Xyz_Library, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Documents and Settings\Administrator\Local Settings\Temp\nunit20\ShadowCopyCache\3816_633640437807493750\Tests\assembly\dl3\e0402b93\6c49ad91_4456c901\Xyz_Library.DLL'.
I think becase the custom type Company are come from difference DLL. But, I still do not know how to get rid of it.
The project source is short like before, and place here: http://www.box.net/shared/1y7o6r5xtu
Or here: http://www.adrive.com/public/76d8dc4...fbfaa853e.html
Hope you can help me again. Thank you very much.
Best regards,
Diviner.
signOut
![]() |
Similar Threads
- Run-time linking of native .dll functions (VB.NET)
- Bluetooth development using platform SDK - error code 10050 (C++)
- Telnet Client (C++)
- C# IE Toolbar talking to C++ BHO (C#)
- php error HELP!!! (PHP)
Other Threads in the C# Forum
- Previous Thread: Error
- Next Thread: changing cell color datagridvew c#
| Thread Tools | Search this Thread |
.net access ado.net algorithm api array barchart bitmap box broadcast buttons c# check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development drag draganddrop drawing encryption enum event excel file files form format forms function gdi+ grantorrevokepermissionthroughc#.net httpwebrequest image index input install java label list listbox listener mandelbrot marshalbyrefobject math mouseclick mysql operator path photoshop php picturebox pixelinversion platform polynomial post programming properties radians regex remote remoting richtextbox serialization server sleep socket sql statistics stream string study table tcp text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf wpfc# xml





