对象没有价值
我对这篇文章的标题感到抱歉,但我不知道如何描述我的问题。
所以,我有以下非常简单的代码:
dynamic obj = new myClass(); // In my case it is a COM object
int FileCount = 0;
FileCount = obj.SomeMethod();
但在运行时我得到这样的东西:
那里发生了什么?为什么Filecount = 0
不是?为什么它是空的?
I am sorry about the title of this post, but I've no idea how to describe my problem.
So, I've got the following really simple code:
dynamic obj = new myClass(); // In my case it is a COM object
int FileCount = 0;
FileCount = obj.SomeMethod();
But at runtime I get something like this:
Whats going on there? Why isn't Filecount = 0
? Why is it null?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您处于发布版本吗?如果 FileCount 未在其他地方使用,则编译器可能会优化该变量。尝试在调试构建中执行此操作。这也可能是由于 pdb 文件不匹配造成的。清理所有输出目录并重新编译应用程序。
Are you in Release build?. If FileCount is not used somewhere else the variable might be optimized out by the compiler. Try doing that in Debug build. Also this can be caused by pdb files mismatch. Clean all your output dirs and recompile the application.
优化了我认为,初始化肯定是毫无意义的
int FileCount = obj.SomeMethod();
因为它是动态的,所以各种编译器魔法都会避免错误,所以我敢说这取决于所有在幕后处理 obj 动态的代码。
Optimised out I should think, the initialisation is certainly pointless
int FileCount = obj.SomeMethod();
Because it's dynamic all sorts of compiler magic happen to evade errors, daresay this one is down to all the code that gets whapped in behind the scenes to deal with obj being dynamic.