简体   繁体   English

“无法加载类型”错误

[英]'could not load type' error

I have a WCF service. 我有WCF服务。 now, I need to create a client that consumes my service. 现在,我需要创建一个使用我的服务的客户端。 when I try to add a service reference from Visual Studio, this is what I get an error message : 当我尝试从Visual Studio添加服务引用时,这就是我收到的错误消息:

"Could not load type 'System.Data.Design.TypedDataSetSchemaImporterExtensionFS35'
 from assembly 'System.Design,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a'".

here's the signature of my service : 这是我的服务签名:

public void SaveBookInDB(byte[] bytesToSave,bool append,Guid guid,String bookname,String contenttype)

I tried using the svcutil.exe at the command-line and I get this : 我尝试在命令行上使用svcutil.exe,我得到了:

"Error : An error occured in the tool. Error : The type initializer for 
'OptionProcessingHelper' threw an exception.
Could not load type 'System.DateTimeOffset' from assembly 'mscorlin, Version=2.0.0.0, 
Culture=neutral,PublickKeyToken=b77a5c561934e089'."

I don't know how to solve this. 我不知道该怎么解决。 can anyone help me please ? 有人可以帮我吗?

even after reinstalling Visual Studio, I still get the same problem. 即使重新安装Visual Studio之后,我仍然遇到相同的问题。

Thanks. 谢谢。

With the question update; 随着问题的更新; if that is the only method in the service (and assuming you don't have any exotic base-classes etc), then I conclude that your VS install is borked. 如果这是服务中的唯一方法(并且假设您没有任何奇异的基类等),那么我得出结论,您的VS安装很麻烦。 Do you have another machine you can try from? 您还有其他机器可以尝试吗? Also, check that your method has the appropriate attributes etc, but that shouldn't cause the problem shown. 另外,请检查您的方法是否具有适当的属性等,但这不应该引起所显示的问题。

Have you tried using svcutil.exe at the command-line? 您是否尝试过在命令行中使用svcutil.exe It is very easy, and hopefully won't have this problem. 这很容易,希望不会出现此问题。

I solved the problem by reinstalling my System and then reinstalling Visual Studio. 我通过重新安装系统然后重新安装Visual Studio来解决了该问题。 and it now Works ! 现在就可以了! Great ! 太好了!

This also happens when Interface declaration differs to the implementation of the Service. 当接口声明与服务的实现不同时,也会发生这种情况。 For example, a function is declared in the Interface and it is implemented, but there is a parameter type discrepancy between the declaration and implementation. 例如,一个函数在接口中声明并实现,但是在声明和实现之间存在参数类型差异。 Then there can be no error in building the project, but attempt to Update Service Reference would fail. 这样,在构建项目时就不会有错误,但是尝试更新Service Reference将失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM