我在Visual Studio 2012中编写了一个C#程序,我遇到了问题.这是我的代码片段:
Process proc = new Process();
proc.StartInfo.Verb = "runas";
proc.StartInfo.FileName = "C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\regasm.exe";
proc.StartInfo.Arguments = "Absolute\\path\\to\\File.dll /codebase /tlb";
proc.Start();
proc.WaitForExit();
MessageBox.Show("Exit code: "+proc.ExitCode);
proc.Close();
Run Code Online (Sandbox Code Playgroud)
问题是,当我构建一个Debug二进制文件并运行它时,它的效果非常好.启动regasm.exe,注册DLL,生成.tlb文件,这都是花花公子.
但是当我运行Release二进制文件时,没有任何工作,MessageBox显示"退出代码:100".我查了一下,但根本没有找到任何有用的东西.
在这里找到我的解决方案:http://objectmix.com/dotnet/320921-regasm-tlb-complaints-element-not-found.html
RegAsm.exe错误是这样的:
RegAsm : error RA0000 : Type library exporter encountered an error while
processing 'Ruby2net.IRuby2net, Ruby2net'. Error: Element not found.
Run Code Online (Sandbox Code Playgroud)
看起来好像是因为我GUID在程序中偶然使用了两次.谢谢大家的时间.
当cout我lettercase变量到控制台时,我得到了-858993460.其他一切似乎都运转正常.我在这里错过了什么?
所以这是我的代码示例:
主要是:
int main()
{
int lettercase = 0;
Switch switcher(lettercase);
lettercase = switcher.getLettercase();
cout << "Lettercase: " << lettercase << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我还有一个单独的类叫Switch.以下是其头文件的示例:
class Switch {
public:
// DEFAULT CONSTRUCTOR
Switch();
// OVERLOAD CONSTRUCTOR
Switch(int);
// DESTRUCTOR
~Switch();
// Lettercase accessor
int getLettercase();
private:
int lettercase;
};
Run Code Online (Sandbox Code Playgroud)
以下是我的定义示例:
// DEFAULT
Switch::Switch() {
int lettercase = 0;
}
// OVERLOAD
Switch::Switch(int lettercase) {
// CHANGE LETTER CASE
if (lettercase …Run Code Online (Sandbox Code Playgroud)