locked
'Windows Form' embedded into an ASP.NET WebPage Issue RRS feed

  • Question

  • User2082192123 posted

     

    Dear All,<o:p></o:p>

    I have some serious issues related to my application and I’m hoping that some of you .Net gurus can help me out in it.<o:p></o:p>

    Overview of my Application:<o:p></o:p>
    Basically, the application (named as CHI) I have created is in a ‘Windows Form’ which uses ‘Web Services’ to connect to the database. The Windows Form is then being embedded into an ASP.<st1:stockticker>NET</st1:stockticker> page to enable it to run over the web as shown in the figure below:

    [
    <st1:stockticker>IMG</st1:stockticker>]Overview of the WebApplication(CHI) Working<o:p>
     </o:p>

    Issue related to CHI:<o:p></o:p>
    The ASP.<st1:stockticker>NET</st1:stockticker> page runs smoothly on localhost as shown below:

    [IMG]http://i206.photobucket.com/albums/bb237/umertahir/CHI_engine_localhost.jpg[/IMG]
     

    <o:p> </o:p>
    Whereas, it displays an empty block where it is supposed to show the embedded Windows Form, when accessed from the client machine, as shown below:<o:p></o:p>
    [IMG]http://i206.photobucket.com/albums/bb237/umertahir/CHI_engine_client.jpg[/IMG]<o:p></o:p>

    <o:p> </o:p>

    Things I Have Already Tried:<o:p></o:p>

    • Added the website URL into the Trusted Sites of the client machine<o:p></o:p>
    • Give ‘Full Trust’ to the website on client’s .Net configuration tool.<o:p></o:p>

    <o:p> </o:p>

    Any sort of help will be much appreciated.<o:p></o:p>

    <o:p> </o:p>

    Thanks<o:p></o:p>

    Umer<o:p></o:p>

    Wednesday, June 20, 2007 6:53 AM

All replies

  • User-768391503 posted

    Here is an article on getting it to run.

    http://bloggingabout.net/blogs/egiardina/archive/2007/04/25/embedding-net-code-and-windows-forms-controls-into-activex-controls.aspx

     Eric
     

    Wednesday, June 20, 2007 8:32 AM
  • User2082192123 posted

    Eric,

    As explained in the article, the following two could be thecommon problems while embedding .Net code & Windows Form into ASP.NET pages:

    • Getting the control to load can be difficult. To make sure the control itself is loading, add a simple button on the user control. If the control loads with the 'image' type square in the top left, and you don't see your button, check the path to the DLL. make sure the DLL is NOT in the Bin folder (IIS will not serve files from the Bin folder).
    • If you get an 'Object does not support this property or method' error client side in your javascript when trying to access public methods of your class, be sure you have ComVisible set to true above your definition (see below). This most often happens with .NET 2.0

     With my application, I have an issuementioned in bullet point one : If the control loads with the 'image' type square in the top left, and you don't see your button

     My 'Windows Form' application's DLLs are not in the Bin folder, the only DLLsi have in myBin folder are:

    • CHI2.dll (CHI2 is my application name)
    • Microsoft.ApplicationBlocks.Data.dll
    • Microsoft.ApplicationBlocks.ExceptionManagement.dll

    The DLLs which are related to my Windows Form are called:

    • SlidersControl.dll <---- This is the main Windows Form application name
    • DundasWinGauge.dll <--- These are the sliding bars I am using in my application made by Dundas
    • SmoothProgressBar.dll
    • ZedGraph.dll <--- A graph representation DLL called ZedGraph

    The above DLLs are NOT in my Bin folder but they are in 'Controls' folder where all the other ASPX pages are located.

     

    So the problem is still there of an empty box. 

    Thursday, June 21, 2007 5:58 AM
  • User-1763423073 posted

    Umer,

    I have the same problem. My DLL is not in the bin folder, but it still shows as an empty box (except for the image icon in the top left).

    Strangely, it seemed to work just the first time I ran the web app - I could see the first few letters of a label in the Winforms control (though surprisingly I couldn't see the whole label - even after setting height and width properties on the <object> tag that were way bigger than the control).

    However, the next thing I did was to add a button and textbox to the control, I rebuilt, copied the updated DLL to the directory in the web app, and ever since then it has shown up as an empty box.

    Still looking for a solution... I wonder if something like an IIS reset is necessary after updating the DLL?

    Wednesday, October 21, 2009 7:33 AM
  • User-1763423073 posted

    Ok, I seem to have made some progress:

    I placed my Winform control DLL in the root directory. Then I used the following markup in my aspx page:

    <object id="testcontrol"
                classid="http:Winform.dll#Winform.UserControl1"
                height="300px" width="300px" style="border:solid 1px black;" VIEWASTEXT/>

    And that seems to work... so far anyway...

    Note how the url portion of the classid begins with "http:" and  then continues with the name of the assembly - no need for "//". Perhaps there is some special notation you are supposed to use if placing the DLL in a subdirectory?

    Wednesday, October 21, 2009 8:27 AM
  • User2082192123 posted

    Can you try adding the link to your trusted website or in local area netwrok trust website  in your browser and then restart your browser.

    Wednesday, October 21, 2009 8:28 AM
  • User-1763423073 posted

    http://localhost is already in my list of trusted websites. I have resarted the browser several times since then.

    Also, the control has stopped working once again. Back to the empty box.

    Wednesday, October 21, 2009 8:57 AM
  • User-1763423073 posted

    Ok, here's a question...

    If I view the properties of my Winforms control DLL, there is a property for "Build Action" with these options:

    • None
    • Compile
    • Content
    • Embedded Resource
    • Application Definition
    • Page
    • Resource
    • SplashScreen
    • EntityDeploy

    Which should it be? I tried 'Embedded Resource' but that still didn't work...

    Wednesday, October 21, 2009 9:02 AM
  • User2082192123 posted

    Have you tried running the webservice from your browser on its own using the exact same http address which is called in your main application?

    Wednesday, October 21, 2009 9:03 AM
  • User-1763423073 posted

    Also, in the <object> tag, is VIEWASTEXT necessary for it to work?

    Wednesday, October 21, 2009 9:04 AM
  • User-1763423073 posted

    Have you tried running the webservice from your browser on its own using the exact same http address which is called in your main application?

    Sorry, there has been some confusion - I'm not using a web service, I've just made a very simple Windows User Control with a button inside it, and I'm trying to display that in a webpage.

    Wednesday, October 21, 2009 9:06 AM
  • User2082192123 posted

    Yes VIEWASTEXT is required.


    Also, in the <object> tag, is VIEWASTEXT necessary for it to work?


    Wednesday, October 21, 2009 9:13 AM
  • User-1763423073 posted

    Could it be something to do with the way I am copying the file from the WindowsControlLibrary project to the WebApplication project? So far I have tried using a post-build event to copy the file, now I'm trying to copy it by hand. Doesn't seem to make a difference... I'm just curious, because it worked the very first time round. It also worked again once about an hour ago.

    What on earth is going on?

    Wednesday, October 21, 2009 9:20 AM
  • User2082192123 posted

    As this is dependant on browser's security settings so most of the time DLLs are blocked by the browsers thinking that it may be some "risky" program.

    i can understand how frustrating it is, thats why I gave up on it after trying to find for a reasonable solution for long time. I suggest you to use different approach like AJAX etc

    Could it be something to do with the way I am copying the file from the WindowsControlLibrary project to the WebApplication project? So far I have tried using a post-build event to copy the file, now I'm trying to copy it by hand. Doesn't seem to make a difference... I'm just curious, because it worked the very first time round. It also worked again once about an hour ago.

    What on earth is going on?


    Wednesday, October 21, 2009 9:31 AM
  • User-1763423073 posted

    As this is dependant on browser's security settings so most of the time DLLs are blocked by the browsers thinking that it may be some "risky" program.

    From the information I can gather from the internet, it's starting to look like browser settings to me aswell. I'm going to adjust them and see if I can get it to work.

    Wednesday, October 21, 2009 9:55 AM
  • User-1763423073 posted

    I've just thought of something else...

    I can't find the .NET Configuration Tool anywhere on my machine, so I haven't been able to do that part of the setup. The tool is not showing up in my control panel. I'll try and find out why.

    Wednesday, October 21, 2009 9:58 AM
  • User2082192123 posted

    See if the link is of any help to you for getting .Net confirguration tool on your machine:

    http://msdn.microsoft.com/en-us/library/2bc0cxhc%28VS.80%29.aspx

    I've just thought of something else...

    I can't find the .NET Configuration Tool anywhere on my machine, so I haven't been able to do that part of the setup. The tool is not showing up in my control panel. I'll try and find out why.


    Wednesday, October 21, 2009 10:19 AM
  • User-1763423073 posted

    I have installed the .Net confirguration tool and given Full Trust to the Trusted Websites zone... and my control still doesn't appear properly...

    Cry

    Wednesday, October 21, 2009 10:30 AM
  • User2082192123 posted

    This freaking thing has caused me a lot of grief as well. I still have not found any good solution so far

    I have installed the .Net confirguration tool and given Full Trust to the Trusted Websites zone... and my control still doesn't appear properly...

    Cry


    Wednesday, October 21, 2009 10:47 AM
  • User-1763423073 posted

    Ok, I had some brief progress...

    I signed the assembly (in the Properties of the WindowsControlLibrary project in which my UserControl belongs).

    Again, it seemed to work for just ONE run of the website after that. Then I added a textbox and a button next to the label that was in the control. Subsequent runs show the old empty box (me and the empty box are like old buddies right now.....)

    Maybe this is a deployment issue. What is the correct way to deploy a signed assembly to a website? Does the .snk file have to go with it?

    Wednesday, October 21, 2009 11:45 AM
  • User-1763423073 posted

    I think I've just worked out how signing works.

    I hadn't realised that if I updated the signed assembly without creating a new snk file, the assembly would no longer work (at least that's how it seems).

    The first time I ran the website after signing the assembly, it worked. Then I made changes in the control and rebuilt the assembly, but I didn't create a new .snk. I tried running the website again, and my embedded objects didn't load. Makes sense.

    So, now I need to find a way to re-sign the assembly on every build. Sounds like a pre or post-build event coming up!

    Wednesday, October 21, 2009 12:20 PM
  • User-1763423073 posted

    Looks like signtool.exe would be the command line app to use to sign assemblies in a post build event. It's included in the .NET Framework 2.0 SDK.

    Strangely though, the /snk parameter is not supported, so I'm not sure how to sign my assembly with an snk. If I use the default option, the signing seems to work, but my UserControl doesn't work. However, if I manually resign the assembly in VS2008, the UserContol does work.

    I could just resign the assembly after every build manually, but that will become tedious very quickly...

    How do I sign with an SNK using signtool.exe?

    Thursday, October 22, 2009 4:13 AM
  • User2082192123 posted

    That is beyond my limited knowledge, I hope someone else can throw some light on it here.

    Looks like signtool.exe would be the command line app to use to sign assemblies in a post build event. It's included in the .NET Framework 2.0 SDK.

    Strangely though, the /snk parameter is not supported, so I'm not sure how to sign my assembly with an snk. If I use the default option, the signing seems to work, but my UserControl doesn't work. However, if I manually resign the assembly in VS2008, the UserContol does work.

    I could just resign the assembly after every build manually, but that will become tedious very quickly...

    How do I sign with an SNK using signtool.exe?


    Thursday, October 22, 2009 4:20 AM
  • User1182639148 posted

    I know this is an old thread, but someone might find this useful. This only applies to when the control works the first time, and then you make a change to it and it stops working.

    The reason the control is not displaying after you rebuild the assembly and copy it over to your webpage's folder is because the assembly is stored on the client's download assembly cache.

    You can either clear the download cache by using the gacutil (gacutil.exe /cdl) or you can simply increment the assembly's version number.

    Thursday, January 20, 2011 7:00 AM
  • User542019825 posted

    Hi All, 

    i have one issue, i just updated teh framework for the and the dll stopped working.

    what could be the reason

    Tuesday, February 13, 2018 6:52 AM