C#引用及其用法 [英] C# references and how they're used
问题描述
(Visual Studio发行日为2008 Professional Edition)
出于好奇:我有一个exe(称为1.exe),该实例化了另一个exe数据(称为2.exe);这很好用.
但是,我需要1.exe的格式对其他exe(other.exe)可用,因此我需要用other.exe实例化该格式;这是我的麻烦突然出现的地方.
我在执行调用2.exe构造函数(2.exe的构造函数之一是1.exe)的1.exe方法中收到类似找不到方法:'Void ... ctor(...)"的错误错误消息的主题).从这里进行调试被证明有些棘手,因为调试器希望逐步浏览我的中间层dll,这在代码方面似乎根本不合适.
我回去打电话给2.exe默认构造函数,当我尝试进入该构造函数时,我收到一条消息,指出调试器没有可用的源.
在进一步摸索和摸索之后,我在other.exe的项目参考列表中添加了对2.exe的参考.注意,没有using子句,只需将引用添加到项目中.
而且,它现在运行良好.
请用几句话告诉我发生了什么事.
谢谢,
Sherril
(Visual Studio 2008 Professional Edition)
Just a curiosity: I have an exe (call it 1.exe) that instantiates another exe for data (call it 2.exe); this works fine.
But, I need the form from 1.exe to be available to another exe (other.exe), so I have other.exe instantiate the form; this was where my trouble popped up.
I got a error like "Method not found: ''Void ...ctor(...)" in the 1.exe method that made the call to the 2.exe constructor (one of 2.exe''s constructors is the subject of the error message). Debugging from here proved a little tricky because the debugger wanted to step through my middle layer dll which didn''t seem at all appropriate in regards to the code.
I went back and put a call to the 2.exe default constructor and when I tried to step into that, I got a message saying the debugger didn''t have the source available.
After further fumbling and bumbling, I added a reference to 2.exe in the other.exe''s project reference list; notice, no using clause, just add the reference to the project.
And, it runs fine now.
In a few short words, please tell me what happened.
Thanks,
Sherril
推荐答案
您的新应用(other.exe)不需要直接引用2.exe,但是1.exe确实需要直接引用.因此,other.exe中不需要using
,但是1.exe需要知道在哪里寻找2.exe并将其放入引用中才能使其找到2.exe.
我希望这是有道理的,我已按照要求故意尝试使用尽可能少的单词. :)
Your new app (other.exe) did not need to refer directly to 2.exe but 1.exe did need a direct reference. Therefore there was no need for ausing
in other.exe but 1.exe needed to know where to look for 2.exe putting in the reference enabled it to find 2.exe.
I hope that this makes sense, I have deliberately tried to use as few words as possible, as requested. :)
这篇关于C#引用及其用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!