Type 'xxx' is not defined, BC30002 error

It is possible to create an instance of a C# class within a aspx.vb codebehind file?

When I try this within the Page_Load event:

Dim oFlow As New Flow(HttpContext.Current.Request)

I get the Type 'Flow' is not defined. The Flow class itself is located here:

App_Code/CSCode/Cust/Frm/Flow.cs

There's no namespace associated with this class.

Any suggestions would be greatly appreciated.

cheers,

devin

Answers


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. 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 a c# class library
  3. Compile that project either in debug or release (this will create a .dll in the projects debug/bin or release/bin folder).
  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.

Now you can call the c# code just as you would any other class library from your VB code. 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.

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.

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 :)

cheers,

devin


Need Your Help

How to get a first word of from a Qstring

qt qstring qregexp

I want to get first word of a Qstring.

Oracle 10g on MacOS Snow Leopard

oracle macos osx-snow-leopard

I've found this helpful tutorial on web