HOWTO: Use C# File (.cs) In VB.NET Solution

  • Thread starter Thread starter Dan Sikorsky
  • Start date Start date
D

Dan Sikorsky

I've included a .cs file in my project that has all .aspx.vb and .vb files,
but can't dim a variable in a .vb file as a .c# class.
Dim objCard as DotNetNuke.CreditCardPurchase
this fails because CreditCardPurchase is not seen in namespace DotNetNuke

Here's the c# file:

namespace DotNetNuke

{

using System;

public class CreditCardPurchase

{

public string host;

public string store_id;

public string api_token;

public string order_id;

public string amount;

public string card;

public string exp;

public string crypt;



public void DoPurchase()

{

HttpsPostRequest mpgReq =

new HttpsPostRequest(host, store_id, api_token,

new Purchase(order_id, amount, card, exp,
crypt));





}



}

}



Where am I going wrong? How do you mix vb and c# files in the same project?
 
Keep the C# assembly separate from your VB project. Just make a reference
to the C# assembly and instantiate the C# class as you would any other
class.
 
Dan,

The easiest way is to put the C# code in a Class Library (DLL) project and
add that to your solution. The other way is to create a multi-file assembly
but that's a pain-in-the-ass and must be done outside Visual Studio.

Hope
 
* "Dan Sikorsky said:
I've included a .cs file in my project that has all .aspx.vb and .vb files,
but can't dim a variable in a .vb file as a .c# class.

Create a C# class library project and reference this project from within
your other project/files.
 
Thanks, I'll try the dll thing.

--
Dan Sikorsky, MSCS BSCE BAB


Rob Windsor said:
Dan,

The easiest way is to put the C# code in a Class Library (DLL) project and
add that to your solution. The other way is to create a multi-file assembly
but that's a pain-in-the-ass and must be done outside Visual Studio.

Hope

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada
this helps,

Dan Sikorsky said:
I've included a .cs file in my project that has all .aspx.vb and .vb files,
but can't dim a variable in a .vb file as a .c# class.
Dim objCard as DotNetNuke.CreditCardPurchase
this fails because CreditCardPurchase is not seen in namespace DotNetNuke

Here's the c# file:

namespace DotNetNuke

{

using System;

public class CreditCardPurchase

{

public string host;

public string store_id;

public string api_token;

public string order_id;

public string amount;

public string card;

public string exp;

public string crypt;



public void DoPurchase()

{

HttpsPostRequest mpgReq =

new HttpsPostRequest(host, store_id, api_token,

new Purchase(order_id, amount, card, exp,
crypt));





}



}

}



Where am I going wrong? How do you mix vb and c# files in the same project?
 
Ok, thanks.

--
Dan Sikorsky, MSCS BSCE BAB


Herfried K. Wagner said:
Create a C# class library project and reference this project from within
your other project/files.
 
Back
Top