简体   繁体   English

未定义类型“ xxx”,BC30002错误

[英]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: 这是我的建议:

  1. Create a new project inside of your solution 在解决方案中创建一个新项目
  2. Create this project as ac# class library 将此项目创建为ac#类库
  3. Compile that project either in debug or release (this will create a .dll in the projects debug/bin or release/bin folder). 在调试或发行版中编译该项目(这将在项目的debug / bin或release / bin文件夹中创建一个.dll)。
  4. Go back to your ASP.Net VB project and make a reference (right click the project in the explorer and your should see the reference option) to the DLL you just created. 返回您的ASP.Net VB项目,然后对刚刚创建的DLL进行引用(在资源管理器中右键单击该项目,您应该会看到引用选项)。

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.

相关问题 抑制状态错误BC30002类型'SpreadsheetGear.Drawing.Image'未定义 - Suppression State Error BC30002 Type 'SpreadsheetGear.Drawing.Image' is not defined 类型“xxx”在未引用的程序集中定义 - The type 'xxx' is defined in an asembly that is not referenced 错误:类型名称“ xxx”在该类型中不存在 - Error: The type name 'xxx' does not exist in the type Url.Action Compilation Error:BC30988:预期为类型或“有” - Url.Action Compilation Error : BC30988: Type or 'With' expected VS2015:在未引用的程序集中定义了类型“ XXX” - VS2015: The type 'XXX' is defined in an assembly that is not referenced 实体类型'xxx'需要主键,但我已经定义了它? - The entity type 'xxx' requires a primary key,but i already defined it? 为什么会得到“在未引用的程序集中定义了xxx类型”? - Why do I get “type xxx is defined in an assembly that is not referenced”? 解析器错误消息:无法创建类型“xxx” - Parser Error Message: Could not create type 'xxx' Split Asp.Net Core Single Project App into multiple projects - 类型与xxx中导入的类型冲突 使用xxx中定义的类型 - Split Asp.Net Core Single Project App into multiple projects - The type conflicts with the imported type in xxx Using the type defined in xxx 未捕获的错误:无法解析绑定;无法解析绑定。 消息:ReferenceError:未定义xxx; - Uncaught Error: Unable to parse bindings; Message: ReferenceError: xxx is not defined;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM