none
Using Visual C# code in Visual Web Developer Express Edition

    Question

  • for aspx development, I'm using Visual Web Developer Express Edition.

    Is there any way to share classes that I develop in Visual C# in Web Developer?

    I know I can copy *.cs files to the "App_Code" folder, but I would prefer to have them both using the same file ( a la "add as link" ).

    Also, when I *do* copy classes to the "App_Code" folder, the web site runs fine in the Web Developer IDE, but if I try to navigate to it in my browser, I get an error message saying it doesn't recognize the class.  ( This is more of a Web Developer question, I grant you, but since I'm on the subject, I hope its alright to ask... )

    Thanks for any help,

    Kirk

     

     

    Thursday, January 18, 2007 10:55 PM

Answers

  • I never knew you are adding everything to the aspx file, usually there is code file attached to every aspx page, if you rite click on your file and say show source, it should come up...

    Or you can do something like this depending on the namespace, say your project was mynamespace...After you add it as refrence...

    <%@ Import Namespace="mynamespace" %>

    the above statement will add the refrence to the dll.....

    and if you are adding it your code file, then should be

    using mynamespace

    Hope this helps...

    Saturday, January 20, 2007 5:10 AM

All replies

  • What exactly you mean by sharing.

    What you can create is a dll of Visual C# classes and let your Website use that .dll, if you don't want to copy in the App_Code folder. making a .dll is much cleaner...

    Friday, January 19, 2007 1:32 AM
  • Lets say I've Declared MyClass in MyNamespace and created MyClass.dll.

    What does the header of my web page look like?

    thanks,

    Kirk

    ps - in my original question, "sharing" meant that I only used one *.cs file for both environments and that any change I made while i was in Visual C# would "automatically" be used by Web Developer.  Said another way, I don't want to wind up with two versions of the same source code.

     

     

    Friday, January 19, 2007 3:07 PM
  • There is no header, Just add the dll to your project by adding a refrence and then say

    using MyNamespace;

    that will you should be able to use the public methods available in dll.....

    ....Sharing I don't know if that will work...The besy way IMHO is dll.....

    Hope this helps.

    Thanks,

    Harsimrat

    Friday, January 19, 2007 7:07 PM
  • I want to make sure I know what you mean.

    Normally, my web pages have what I call a "header" - the first few lines at the top, that look something like this:

    <%@ Page Language="C#" Debug="true"%>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %>


    I thought that I would need another "import" to bring in the DLL.

    If that is not the case, where do I put a "using" in in a web page?  At the top of the script section?

    In other words, like this?

    <script language="C#" runat="server" >

    Using MyNamespace;

    ( .... some code )

    </script

     

     

    Friday, January 19, 2007 9:06 PM
  • I never knew you are adding everything to the aspx file, usually there is code file attached to every aspx page, if you rite click on your file and say show source, it should come up...

    Or you can do something like this depending on the namespace, say your project was mynamespace...After you add it as refrence...

    <%@ Import Namespace="mynamespace" %>

    the above statement will add the refrence to the dll.....

    and if you are adding it your code file, then should be

    using mynamespace

    Hope this helps...

    Saturday, January 20, 2007 5:10 AM