(带SQLite的UserControl)--->无法创建组件'UserControl1',System.DllNotFound除外,无法加载Sqlite.interop.dll [英] (UserControl with SQLite) ---> Failed to create components 'UserControl1', System.DllNotFound Excpetion, Unable to Load Sqlite.interop.dll
问题描述
我使用Sqlite进行了用户控制。编译并添加到工具箱后,通过将其拖动到新窗体中,将出现如下所述的错误消息:
I had a user control with Sqlite. After Compiled and Added to the Tool Box, by dragging it into a new Form,an Error Message as described Below:
无法创建组件'UserControl1'。错误消息遵循'System.DllNotFoundException:'无法加载Dll'Sqlite.Interop.dll':找不到指定的模块。HResult的异常:0x8007007E
"Failed to Create Component 'UserControl1'. The Error Message follows 'System.DllNotFoundException: 'Unable to Load Dll 'Sqlite.Interop.dll' : The Specified Module could not be found. Exception from HResult: 0x8007007E
我用Google搜索关于这个问题,我仍然无法解决这个问题,但是有趣的部分是,如果我通过引用将
硬编码到Form中并创建一个新控件,则该用户控件可以正常工作。
I googled on this subject, I'm still unable to resolved this issue. But the funny parts is If I hard coded it in the Form by reference and create a new control, the user control worked. Why Drag and Drop had this problem?
一个问题:我正在使用Nuget安装sqlite,有2个版本:32和64位:
其中一个我应该添加作为参考吗?
我正在使用VS2010 Ultimate sp1。Sqlite v 1.0.83.0。dll作为任何cpu编译。
One more Question: I'm using Nuget to install sqlite, there are 2 version: 32 and 64 bit: which one should i add as reference? I'm using VS2010 ultimate sp1. Sqlite v 1.0.83.0. Compiled dll as any cpu.
推荐答案
我认为这是与SQLite分开的问题,更具体地讲,当您尝试拖动DLL时找不到DLL。用户从工具箱中进行控制。我有同样的问题。我可以通过 Controls.Add(myUserControl)
以编程方式添加用户控件,它工作正常,但无法将其从工具箱中拖动。一些搜索使我找到了Hans Passant的见解以下链接:
I think this is an issue separate from SQLite and more specifically deals with the DLL not being found when you try to drag the user control from the Toolbox. I had the same problem. I was able to programmatically add the user control via Controls.Add(myUserControl)
and it worked fine but I couldn't drag it from the Toolbox. Some searching led me to the following link with insight from Hans Passant:
要点是设计者没有不知道在哪里查找DLL的路径。作为测试,我在 DllImport
中硬编码了路径,即 [DllImport(* full path here *)]
,并且我能够成功地将用户控件从工具箱拖到设计器中。 (确保在添加完整路径后尝试添加用户控件,然后再进行构建!)
The gist is that the Designer doesn't know the path for where to look for the DLL. As a test, I hard-coded the path within DllImport
i.e. [DllImport(*full path here*)]
, and I was able to successfully drag the user control from the Toolbox to the Designer. (Make sure you do a build after adding the full path before trying to add the user control!)
没有进行任何重大测试,看来我随后便可以删除完全合格的路径,设计师似乎记得要看哪里。我可以从表单中删除用户控件,然后再次添加它而不会出现问题。但是,一旦我关闭Visual Studio并重新打开它,将用户控件从工具箱中拖放的操作再次失败。希望这些信息可以帮助某人了解正在发生的事情和/或引导他们朝着正确的方向寻求解决方案。
Without any major testing, it seems I was then able to then remove the fully qualified path and the Designer seemed to remember where to look. I could delete the user control from the form and add it again without issue. Once I closed Visual Studio and re-opened it, though, dragging and dropping the user control from the Toolbox failed again. Hopefully this information can help someone understand what's going on and/or lead them in the right direction for a solution.
这篇关于(带SQLite的UserControl)--->无法创建组件'UserControl1',System.DllNotFound除外,无法加载Sqlite.interop.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!