简体   繁体   English

LuaInterface-在.Net 3.5 / .Net 4.0下编译FileLoadException

[英]LuaInterface - Compiling under .Net 3.5 / .Net 4.0 FileLoadException

A project of mine utilizes LuaInterface. 我的一个项目利用LuaInterface。 I've begun migrating it from XNA to OpenTX, as well as rewriting it under .Net 4.0. 我已经开始将其从XNA迁移到OpenTX,并在.Net 4.0下进行重写。

I started moving my Lua class over, to find that i get an exception when debugging (FileLoadException) 我开始移动我的Lua类,以发现调试时出现异常(FileLoadException)

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

When i rebuilt LuaInterface, i changed the .Net Framework in its properties from .Net 2.0 to .Net 4.0 (as well as its client mode) and .Net 3.5. 当我重建LuaInterface时,我将.Net Framework的属性从.Net 2.0更改为.Net 4.0(以及其客户端模式)和.Net 3.5。

Both of these settings give me the error stating its still built using 2.0. 这两个设置都给我错误,指出它仍然使用2.0构建。

I've attempted many solutions here at StackOverflow as well as MSDN, stating to setup an app.config and even change Application Pools for some ungodly reason... 我已经在StackOverflow和MSDN上尝试过许多解决方案,它们指出要设置app.config甚至出于某些不可思议的原因而更改应用程序池...

Anyway, every solution i've attempted failed, stating that its STILL using 2.0. 无论如何,我尝试过的每个解决方案都失败了,说明它仍然使用2.0。

I've used 'IL DASM' and it states its built using 3.5/4.0. 我用过“ IL DASM”,它表示使用3.5 / 4.0构建。

Any ideas as to whats going on? 有什么想法吗? Been messing with this all day. 整天都在混乱。 Am I simply being naive to think that changing a single setting could fix my problems? 我只是天真地认为更改单个设置可以解决我的问题吗?

Any help would be GREATLY appreciated. 任何帮助将不胜感激。

I had the same problem when I tried to integrate LUA code with my .NET4.0 project. 当我尝试将LUA代码与.NET4.0项目集成时,我遇到了同样的问题。 I didn't rebuild the .dll because I couldn't check-out the LuaInterface project files from their repository. 我没有重建.dll,因为无法从其存储库中检出LuaInterface项目文件。 Anyway, I rewrote the app.config for my small test application and it seems to work, so far. 无论如何,我为我的小型测试应用程序重写了app.config,到目前为止,它似乎仍然有效。

The xml lines you need to rewrite are: 您需要重写的xml行是:

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>

I couldn't tell you how robust this method is, since I only tried some simple stuff like read/write string, doFile, etc. 因为我只尝试了一些简单的东西,如读/写字符串,doFile等,所以我无法告诉您该方法的鲁棒性。

Hope it works for you as well. 希望它也对您有用。

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

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