[英]Type 'xxx' is not defined, BC30002 error
It is possible to create an instance of a C# class within a aspx.vb codebehind file? 是否可以在aspx.vb代码隐藏文件内创建C#类的实例?
When I try this within the Page_Load event: 当我在Page_Load事件中尝试此操作时:
Dim oFlow As New Flow(HttpContext.Current.Request)
I get the Type 'Flow' is not defined. 我得到类型“流”未定义。 The Flow class itself is located here:
Flow类本身位于此处:
App_Code/CSCode/Cust/Frm/Flow.cs
There's no namespace associated with this class. 没有与此类关联的名称空间。
Any suggestions would be greatly appreciated. 任何建议将不胜感激。
cheers, 干杯,
devin 德文
There seems to be a few articles on google which say that it is possible to call a C# class from VB directly using a reference. Google上似乎有几篇文章说可以使用引用直接从VB调用C#类。 However I have never used this method before.
但是我以前从未使用过这种方法。 Here is what I would suggest:
这是我的建议:
Now you can call the c# code just as you would any other class library from your VB code. 现在,您可以像调用VB代码中的任何其他类库一样调用c#代码。 Also, if you need to make changes to the C# code all you have to do is make them, compile again, and since it is referenced in your VB project everything will be updated auto-magically.
另外,如果您需要对C#代码进行更改,则只需进行更改,然后再次编译,由于VB项目中已引用了该代码,因此所有内容都会自动进行神奇地更新。
Hope this helps. 希望这可以帮助。
Thanks for the response. 感谢您的回复。
The reason why I was having issues is because I'm using IIS 6 on my windows xp box along with the XP PRO IIS Admin Tool and I didn't have the correct site running. 我遇到问题的原因是因为我在Windows XP盒子上使用IIS 6以及XP PRO IIS Admin Tool,而我没有运行正确的站点。
Once I switched over to the proper site within the XP PRO IIS Admin Tool and then recompiled, I was able to call my C# class from within the .vb page without a hitch and intellisense recoginized the class as well :) 一旦我切换到XP PRO IIS Admin Tool中的适当站点,然后重新编译,就可以从.vb页面中调用C#类,而不会遇到麻烦,并且Intellisense也可以重新识别该类:)
cheers, 干杯,
devin 德文
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.