Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Cannot register application by UltiDevCassiniServerConfiguration.dll in VS2010
zhlei616
#1 Posted : Thursday, January 27, 2011 3:27:13 AM(UTC)
Groups: Member
Joined: 1/27/2011(UTC)
Posts: 4
Location: Shanghai

I have a deployment project using UltiDevCassiniServerConfiguration.dll to register application automatically in VS2008, it worked well.
After switch to VS2010, I followed the descriptions in "Can I build a deployment package with Cassini in Visual Studio 2010?" to add the prerequisite,
and did nothing to the project. After installed the package, cassini server don't run, it shows "cannot display the webpage" even when the cassini server runs OK before install the package.
So I removed "UltiDevCassiniServerConfiguration.dll" and customer actions in the deployment project, then install the package, configurate the application manually in Cassini Web Server Explore, then it runs well.
This problem perplexed me a whole day, the users can't configurate the application themselves.
In the event viewer, there is a warning "Server object was discarded for Cassini web application [7756,"UltiDev Cassini Web Server Explorer"]."
and some errors"The UltiDev Cassini Web Server for ASP.NET 2.0 service terminated unexpectedly. It has done this 1 time(s)."
Ultidev Team
#2 Posted : Thursday, January 27, 2011 5:39:34 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi!

There might be a couple of different problems. One is application is not running after installation, and another is web server process being terminated unexpectedly.

To diagnose the first problem, could you please check whether UltiDev Web Server was installed properly by your installation package. For example, when you add it as a prerequisite, you should run Setup.exe, not your package MSI, because only Setup.exe can install prerequisites before launching your MSI. To verify whether UltiDev Cassini got installed, please browse to http://localhost:7756/ after your installer ran and see if Cassini Explorer page is available. If it's not, please go to the Control Panel and use "Programs and Features" (Windows 7 and Vista) or "Add/Remove Programs" on Windows XP to see whether UltiDev Cassini components were installed.

Regarding unexpected termination problem, it means that the Cassini windows service has crashed, which could be caused either by a bug in the Cassini Server itself, or a bug in an application it hosts. To determine whether it's a web server problem, please unregister all applications and run only Cassini Explorer at http://localhost:7756/ to see whether using Cassini Explorer also makes server crash.

Please let us know what you have found.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
zhlei616
#3 Posted : Thursday, January 27, 2011 5:52:26 PM(UTC)
Groups: Member
Joined: 1/27/2011(UTC)
Posts: 4
Location: Shanghai

Thank you for reply.
There are 2 project in my solution, one is a very simple web application only contains a Label, its target .net framework is 3.5.
Another is the setup project using cassini server and the register configuration dll, its target .net framework and launch condition both are .net framework 2.0.
The version of Visual Studio is 2010.
The issue is that after installed the package(AppKeepRunning="false"), cassini server was OK until that time, but the "Target ASP.NET Version" was set to "4.0" for this appliction.
I tried to set Target ASP.NET Version to 2.0, then cassini server was crashed.
The error in Event Viewer of Windows 7 is:
An unhandled exception occurred and the process was terminated.

Application ID: UltiDevCassinWebServer2a.exe

Process ID: 5712

Exception: System.ArgumentException

Message: The parameter 'C:\Program Files\Default Company Name\TestCassiniSetup\\' is invalid.
Parameter name: C:\Program Files\Default Company Name\TestCassiniSetup\\

StackTrace: at System.Web.Hosting.SimpleApplicationHost..ctor(VirtualPath virtualPath, String physicalPath)
at System.Web.Hosting.ApplicationManager.CreateObject(String appId, Type type, String virtualPath, String physicalPath, Boolean failIfExists, Boolean throwOnError)
at System.Web.Hosting.ApplicationManager.CreateObject(String appId, Type type, String virtualPath, String physicalPath, Boolean failIfExists)
at Cassini.Server.GetHost()
at Cassini.Server.OnSocketAccept(Object acceptedSocket)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)


In XP, the error is:
EventType clr20r3, P1 ultidevcassinwebserver2a.exe, P2 2.1.2595.184, P3 45caafc1, P4 system.web, P5 2.0.0.0, P6 4ba859d5, P7 2357, P8 21, P9 system.argumentexception, P10 NIL.
Ultidev Team
#4 Posted : Friday, January 28, 2011 4:52:08 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi there!

Thank you for submitting the exception details. From the error report it appears that registered physical path of the application has double-backslash at the end of the "C:\Program Files\Default Company Name\TestCassiniSetup\\" path when creating an ASP.NET AppDomain for your application. Please try ensuring that it's just a single backslash and see whether this will help. We will fix registration in the next release of UltiDev Web Server so that incorrect physical paths will be rejected at the registration phase instead of being rejected at run time.

Please let us know if this information has helped.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
zhlei616
#5 Posted : Friday, January 28, 2011 9:09:03 PM(UTC)
Groups: Member
Joined: 1/27/2011(UTC)
Posts: 4
Location: Shanghai

Thank you very much!It really helped me.
But a new issue occured after changing "/AppLocation="[TARGETDIR]\" to "/AppLocation="[TARGETDIR]"
It caused another error:
Error 1001. Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\system32\Files\CompanyName\ProductName\bin\UltiDevCassiniServerConfiguration.dll' or one of its dependencies. The system cannot find the file specified..
as same as case http://ultidev.com/Forum....aspx?g=posts&t=296 you have dealed with.
That means I can't change "/AppLocation="[TARGETDIR]\" to "/AppLocation="[TARGETDIR]", and in the installation folder dialog window, there is only 1 backslash at the end of the "Folder" textbox,
I tried to remove the last backslash in the textbox when installing, make it like "C:\Program Files\Company\Product", but the first issue "physicalPath is invalid" occured again,the parameter was still "C:\Program Files\Company\Product\\"
Is it caused by the difference of "TARGETDIR(installation phsical path)" between VS2008 and VS2010?
Ultidev Team
#6 Posted : Saturday, January 29, 2011 12:05:55 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi!

You are probably right: it appears that there is a difference in the value of [TARGETDIR] setup project property between VS 2010 and 2008 - backward compatibility does not always seems to be a concern of Microsoft.

Could you please try "/AppLocation="[TARGETDIR]\." and "/AppLocation="[TARGETDIR]\.\"? If that does not help, we'll help you call registration API from your Installer.cs class.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
zhlei616
#7 Posted : Tuesday, February 8, 2011 4:40:44 PM(UTC)
Groups: Member
Joined: 1/27/2011(UTC)
Posts: 4
Location: Shanghai

Sorry, I reply late, cause last week was Chinese New Year, I was on holiday.
Thank you for your help, I've tried "/AppLocation="[TARGETDIR]\." and "/AppLocation="[TARGETDIR]\.\",
but they didn't resolve this problem.
The first one caused cassini server crashed, the second one caused FileNotFoundException when installing.
Ultidev Team
#8 Posted : Wednesday, February 9, 2011 6:53:12 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Happy holidays!

Could you please try the following:
- Create a Class Library project and add an Installer class.
- Expose the DLL built at the previous step to custom installer steps.
- Put breakpoint in your Installer class's Install() and Commit() methods to get the value of "AppLocation" parameter. It will let you modify custom installer arguments for our custom installer accordingly, or
- If that cannot be done, you could simple massage "AppLocation" in the code and them call our config API RegisterApplication() method from your code to work around the issue.

Please let us know if this information was helpful.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
dombat
#9 Posted : Wednesday, March 16, 2011 5:06:20 AM(UTC)
Groups: Member
Joined: 11/18/2010(UTC)
Posts: 13
Location: UK

Was there any further feedback on this issue? I'm having exactly the same problem now (my company uninstalled 2008 so we only have 2010).

Also, could you elaborate on this, as it doesn't make much sense: (e.g. how do you run the class, as I installed it and nothing happened so I'm doing it wrong)
Quote:
Could you please try the following:
- Create a Class Library project and add an Installer class.
- Expose the DLL built at the previous step to custom installer steps.
- Put breakpoint in your Installer class's Install() and Commit() methods to get the value of "AppLocation" parameter. It will let you modify custom installer arguments for our custom installer accordingly, or
- If that cannot be done, you could simple massage "AppLocation" in the code and them call our config API RegisterApplication() method from your code to work around the issue.
(editied for spelling 24/3/11)
Ultidev Team
#10 Posted : Wednesday, March 16, 2011 10:42:49 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi there!

We've done our own test and were able to confirm that it's probably a VS 2010 Setup & Deployment project bug. The installer generated by Visual Studio 2010 will fail during installation unless TARGETDIR parameter is passed with a trailing backslash: /AppLocation="[TARGETDIR]\". However, that required trailing backslash leads to duplicate backslash in the directory path, and needs to be stripped out before registering an application with UltiDev Cassini.

Here's how you go about dealing with this issue. You will need to do create an Installer class. The best place to put it is a separate Class Library project. After you have added an Installer class to a DLL project, you need to wire the DLL to Setup project's custom actions. To do that you could follow this MSDN article starting from "To add the custom action" section, or look at this part of UltiDev Cassini developer's guide (only instead of using UltiDevCassiniServerConfiguration.dll as a custom action target, you'll use your own Class Library or EXE assembly with the Installer.cs class having the code below).

The code below is taken from UltiDev Cassini Configuration installer class, updated to handle Visual Studio 2010 parameter problem and can be used freely to replace Installer implementation from UltiDevCassiniServerConfiguration.dll.

Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;

namespace UltiDev.Cassini
{
    [RunInstaller(true)]
    public class Installer : System.Configuration.Install.Installer
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public Installer()
        {
            // This call is required by the Designer.
            InitializeComponent();
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }


        #region Component Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
        }
        #endregion

#region BL Methods
private void RegisterApplication(IDictionary stateSaver)
{
string step = string.Empty;
try
{
step = "converting appID parameter to GUID";
string appIDString = Context.Parameters["appid"];
Guid appID = new Guid(appIDString);

step = "getting appLocation parameter value";
string appLocation = Context.Parameters["applocation"];
if (appLocation == null || appLocation.Length == 0)
throw new ApplicationException("Unable to register application. AppLocation parameter is not specified.");
appLocation = appLocation.TrimEnd('\\'); // Added to work around VS 2010 parameter bug

step = "getting appName parameter value";
string appName = Context.Parameters["appname"];

step = "getting appDescription parameter value";
string appDescription = Context.Parameters["appdescription"];

step = "getting appPort parameter value";
int port = 0;
string portValue = Context.Parameters["appport"];
if (portValue != null && portValue.Length > 0)
port = int.Parse(portValue);

step = "getting appDefaultDoc parameter value";
string defaultDocument = Context.Parameters["appdefaultdoc"];

step = "getting appKeepRunning parameter value";
string keepRunningString = Context.Parameters["appkeeprunning"];
bool keepRunning = true;
if (keepRunningString != null && keepRunningString.Length > 0)
keepRunning = bool.Parse(keepRunningString);

step = "calling CassiniConfiguration.Metabase.RegisterApplication() method";
CassiniConfiguration.Metabase.RegisterApplication(
appID, appName, port, appDescription,
appLocation, defaultDocument, keepRunning);

stateSaver["AppID"] = appID.ToString();
}
catch (Exception e)
{
string msg = string.Format("Failed to register an application with Cassini while {0}.", step);
throw new Exception(msg, e);
}
}

private void UnregisterApp()
{
string step = string.Empty;
try
{
step = "converting appID parameter to GUID";
string appIDString = Context.Parameters["appid"];
Guid appID = new Guid(appIDString);

step = "calling CassiniConfiguration.Metabase.UnregisterApplication(appID) method";
CassiniConfiguration.Metabase.UnregisterApplication(appID);
}
catch (Exception e)
{
string msg = string.Format("Failed to unregister Cassini application while {0}.", step);
throw new Exception(msg, e);
}
}

#endregion BL Methods

#region Installer class implementation
/// <summary>
/// Install should not be used with VS 2008-generated MSI
/// because Install is called BEFORE Uninstall.
/// </summary>
/// <param name="stateSaver"></param>
        public override void Install(IDictionary stateSaver)
        {
            base.Install (stateSaver);
        }

public override void Commit(IDictionary savedState)
{
base.Commit(savedState);

this.RegisterApplication(savedState);
}

        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall (savedState);

            this.UnregisterApp();
        }

        public override void Rollback(IDictionary savedState)
        {
            base.Rollback (savedState);

            this.UnregisterApp();
}
#endregion Installer class implementation
}
}


Please let us know if this has helped.

Cheers,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Mateusz
#11 Posted : Wednesday, March 30, 2011 4:51:09 AM(UTC)
Groups: Member
Joined: 3/29/2011(UTC)
Posts: 4
Location: Warsaw

Hi,

I have the same problem during installation with [targetDir] with VS2010.

I am trying to apply above code in a way:

1. I created new, my own class library
2. Copy above code ( only namespace remain different than from above code )
3. I got error:

"CassiniConfiguration" namespace is not recognized in code.

What i did is adding your UltiDevCassiniServerConfiguration.dll to references of
my new class and it is OK, CassiniConfiguration is now recognized.

MyUltiDevCassiniServerConfiguration.dll is generated using orginal UltiDevCassiniServerConfiguration.dll ( in rereferences )

4. I added MyUltiDevCassiniServerConfiguration.dll to FileSystem -> Application Folder -> Bin instead existing UltiDevCassiniServerConfiguration.dll,
but i have got error:

Unable to find dependency 'ULTIDEVCASSINISERVERCONFIGURATION' (Signature='1C67998C33839163' Version='1.1.0.3') of assembly 'MyUltiDevCassiniServerConfiguration.dll'

Means i should add orginal dll = UltiDevCassiniServerConfiguration.dll also ? But how ?
What i am doing wrong ?


Thanks a lot for any help !

Kind Regards,
Mateusz


Ultidev Team
#12 Posted : Wednesday, March 30, 2011 4:30:02 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hello, Mateusz.

Congratulations on successful work-around.

Yes, you need to include original UltiDevCassiniServerConfiguration.dll as shown here because you still call it. It does not necessarily need to be added to the Bin folder - it needs to be in the same folder as your assembly with the Installer class. For example, you could have two folders under "Application Folder": one is "WebApp" and another one is "Installer". You could put your application in the WebApp folder, and the installer assembly and Cassini config DLL into the Installer folder. Your web application does not need to reference either your installer or Cassini config DLL - your web app can be completely unaware of both.

Please let us know if this information was helpful.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Mateusz
#13 Posted : Thursday, March 31, 2011 6:02:52 AM(UTC)
Groups: Member
Joined: 3/29/2011(UTC)
Posts: 4
Location: Warsaw

Hi,

Thanks for help. Now, there is no error after installation like it was before with orginal .dll,
but I don't see my application registered in Cassini Web Server Explorer at http://localhost:7756/
Web server application is installed properly.

Do you know what could be wrong, are you sure this code works OK ?
Maybe could you send me example of project in vs2010 for Win7 which you test and works ?

Thanks in advance for your help.

Regards,
Mateusz
Ultidev Team
#14 Posted : Thursday, March 31, 2011 6:25:08 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hello, Mateusz.

Please check whether CassiniConfiguration.Metabase.RegisterApplication() call in the code snippet we provided actually is executed and whether it modifies "C:\ProgramData\UltiDev\Cassini\CassiniMetabase.xml" file with the configuration of your application. If not, please check Windows Event Log whether anything is logged there. You could also add System.Diagnostic.Trace.TraceError() statements to the Cassini registration snippet to log the execution progress and see whether registration completed successfully.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Mateusz
#15 Posted : Monday, April 4, 2011 1:13:58 PM(UTC)
Groups: Member
Joined: 3/29/2011(UTC)
Posts: 4
Location: Warsaw

Hi,

It occurs that dll should also be added to Commit Custom Action not only to Install Custom Action.
After added the same modified dll to these 2 actions it works ok.

In other words, on install action there is no registration invoked ( above code ).
Do I am right ?

Regards,
Mateusz
Ultidev Team
#16 Posted : Monday, April 4, 2011 4:27:10 PM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
You're right, Mateusz.

In fact, you need to hook up all four custom actions: Install, Commit, Uninstall and Rollback. Technically, Install action doesn't do anything useful, so you don't have to hook it up, but if you decide to add some code to it later, it's going to be already called by the installer. But three remaining custom actions need to be hooked up.

Please let us know if this information was helpful.

Cheers,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.