从3.5至4.5场所依赖性升级.NET依赖性、场所、NET

2023-09-04 01:21:39 作者:注定一生孤妄

针对.NET 3.5框架项目现有的应用程序使用一个第三方的DLL。我决定重新目标至4.5尽量使用默认的CultureInfo设置。

重新定位之后,code调用第三方DLL不能编译了。

这是一个多语言的应用程序(Engish /法国),我觉得这可能是一些与它做的是从构建错误列表现在即将在法国。在3.5错误列表是英文的。

该错误消息的我的内部pretation是:

 不可能合并式互操作Envox.ADXVoice.ADXVoiceClass。 Utilise接口适当的地方。
 

该应用程序有一个有条件地调用法国文化不同的线程,它本来不错下移考不上一个基类,设置应用程序默认文化。

任何人都达成了类似的问题?

逐字的错误是:

 错误7不可能D'incorporer文件类型的互操作Envox.ADXVoice.ADXVoiceClass。 Utilisez L'接口适用点菜的地方。
 

解决方案

英语错误消息是:

  

错误CS1752:互操作型Envox.ADXVoice.ADXVoiceClass无法嵌入。使用适用的接口,而不是。

据生成的,因为你有嵌入互操作类型属性设置为True在Envox互操作库。在.NET 4.0中的新功能,的非常的理想的,因为你不再需要再部署互操作库或PIA的。它需要你使用一个稍微不同的编程风格,创建COM服务器的一个对象:

  VAR OBJ =新Envox.ADXVoice.ADXVoice();
 
基于PROFINET的实现方案

在换句话说,您使用的新的操作员的接口类型,而不是类的类型。 C#程序员往往打击,当他们看到这样的密封垫,它通常是完全非法的。但它是准确的,COM对象在C#中的处理方式有点不寻常。否则,它适合COM编程模型好了,你严格与COM接口工作。

您还可以设置嵌入互操作类型属性设置回为False,所以你不会做任何code的变化。有点浪费,真的。

FWIW,你很可能会提前通过让你的C#编译器会说英语,而不是法国。检查这个答案。

An existing application targeting .NET 3.5 framework project uses a 3rd Party DLL. I decided retargeting to 4.5 to make use of default CultureInfo setting.

After retargeting, code calling the third party dll does not compile anymore.

It is a multi-language app (Engish / French) and I feel that this may be something to do with it as the error list from the build is now coming up in French. In 3.5 error list is in English.

My interpretation of the error message is:

"Impossible to incorporate the type interop 'Envox.ADXVoice.ADXVoiceClass.' Utilise the interface appropriate to the place." 

The app has various threads that conditionally invoke French culture and it would have been nice to move the test down into a base class and set the applications Default Culture.

Anybody struck a similar problem?

The verbatim error is:

Error   7   Impossible d'incorporer le type interop 'Envox.ADXVoice.ADXVoiceClass'. Utilisez l'interface applicable à la place. 

解决方案

The English error message is:

error CS1752: Interop type 'Envox.ADXVoice.ADXVoiceClass' cannot be embedded. Use the applicable interface instead.

It is generated because you have the "Embed interop types" property set to True on the Envox interop library. A new feature in .NET 4.0, extremely desirable because you no longer have to deploy interop libraries or PIAs anymore. It does require you to use a slightly different programming style, you create an object of that COM server with:

  var obj = new Envox.ADXVoice.ADXVoice();

In other words, you use the new operator on the interface type, not the class type. C# programmers tend to blow a gasket when they see this, it is normally completely illegal. But it is accurate, the way COM objects are treated in C# is a bit unusual. It otherwise fits the COM programming model well, you strictly work with interfaces in COM.

You can also set the "Embed interop types" property back to False so you won't have to make any code changes. Bit of a waste, really.

Fwiw, you would probably be ahead by having your C# compiler speak English instead of French. Check this answer.