0
votes

I have a web application with a small plugin architecture that dynamically loads a dll file in its bin directory. This has been working very well. However, I have implmented a web service client in this plugin and when I try to make a request I get the following error:

[A]Shop.Plugin.Store.StockService.Input cannot be cast to [B]Shop.Plugin.Store.StockService.Input. Type A originates from 'Shop.Plugin.Store, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:\Users\User\Code\Shop 1.1\Web\Bin\Shop.Plugin.Store.dll'. Type B originates from 'Shop.Plugin.Store, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\7aef619a\99a65b99\assembly\dl3\b7917cf6\32a0370a_064ad101\Shop.Plugin.Store.dll'.

The Input class is defined as followed:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.208")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace="urn:Services.productStockLevelService.Classes")]
public partial class Input { ... }

I know that .NET creates the DLL files in its temporary folder. Also, I have never had problems with that. This changed with adding the web service.

1

1 Answers

0
votes

I think that I have found the solution. In my application I have loaded the plugin assembly with the command:

Assembly.LoadFile("...");

I have changed this line now to:

Assembly.LoadFrom("...");

Now it is working properly.