using C# in a VB.Net project

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a 3rd party ecommerce application writen in VB.NET. I have
developed a couple c# addons that I would like to integrate into the
ecommerce site, more specifically I need to share session information across
the pages.

Can it be done?

Thanks, Justin.
 
Once compiled, a C# DLL is no different than a VB.Net DLL. As for
integrating your add-ons with a 3rd party application, I suppose that
depends on the add-ons and the 3rd party application. I can use the same
metal to build a car or a toaster. But try finding a plug in a car that you
can plug your toaster into!

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
you'd need to put your C# code in a seperate project/assembly since you
can't have Both in the same project.

Now the problem is...the ASP.NET project is VB and the other project is a C#
Class Library. How do you get to all the good HTTP Stuff with C#?

In your C# project, make sure there's a reference to the System.Web
Namespace.
To get the HTTP stuff, try
System.Web.HttpContext ctx = System.Web.HttpContext.Current;

from there, you can get the ctx.Session, ctx.Response, ctx.Request
(of if you want to be REALLY cool...)
System.Web.Ui.Page thePage = (System.Web.Ui.Page)ctx.Handler;

If you want to cast the handler into your specific type of page, you're
going to have to have more than 2 projects...otherwise you'd end up with a
circular reference.
 
If you can have a aspx pages with vb.net code behind and aspx pages with c#
code behind within the same web application it is possible to share the
session. As it is the application context that holds the session
information. You need to try that.

But if you cannot have aspx vb.net and aspx c# run in the same web
applicationd then you won't be able to share the session in an other way
that doing it manually (request strings, DB, cookies maybe?).
But also check out also the option to run the storage of the Session
information out of process.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.asp
But I think that it may not help as if the pages run from different
applications they should not share the Session anyway. But as i never tried
the out process model, I am not sure. I am just trying to give you a few
hints for you to have a look at.

Best regards,

Francois
 
Back
Top