"Single instance application": Multiple instances in Windows 2008 terminal server environment - vb.net

I have a small VB.NET application to handles a custom URL protocol. It is set up in Visual Studio with the option to "Make single instance application". This has worked for hundreds of installations, but a recent customer is using Windows Terminal Server 2008, and it is launching multiple copies of the application. It does not seem to sense that it is already running for a specific user. BTW -
Multiple users can run it without problems in different sessions.
Is there some sort of setting on the Windows Terminal server that could cause this?
We have installed the application using install mode, and with the administrator ID.
Any ideas would be appreciated.

Related

Can the Lotus Designer 8.5.3 FP6 client run on Windows Server 2012 Standard VM

The overall picture that I am trying to achieve is for me and three other people to connect remotely to a client's network and use Lotus Designer 8.5.3 FP6 to access the client's Domino servers. We will each have our own logons to the client's Citrix environment which runs a Windows 7 desktop, then using Remote Desktop concurrently connect to PC(s) within the client's network to run Lotus Designer from there. (Lotus Designer is not available on the Citrix desktop.)
The issue is that the client is wanting to avoid having four separate physical PCs set up waiting for us to log in. They have Windows Server 2012 Standard virtual machines available.
First question: Can the Lotus Designer client 8.5.3 FP6 run on Windows Server 2012 Standard VM? I know that it is not officially supported, but is there any reason why it wouldn't work?
If it can run, then the second question: Is it possible for all four people to use remote desktop to concurrently log in to one Windows Server 2012 Standard VM, which has a separate instance of Lotus Designer 8.5.3 FP6 installed per user? (and of course run the separate instances of Designer concurrently) Or would we need four separate Windows Server 2102 Standard VMs?
Thanks for any light that can be shed on these questions.
First of all: Designer 8.5.3FP6 will run on Windows Server 2012 although not officially supported.
To start the designer concurrently you need to "fake" a multiuser- installation:
Before installing create an extra drive, e.g. by using "subst".
You might need to do this twice, once for the user himself, once in an elevated prompt, so that installer can access it.
e.g. subst D: C:\NotesUserA
Then you install program and data directory into D:
After that you copy C:\NotesUserA\IBM\Notes to C:\NotesUserB\IBM\Notes, C:\NotesUserC\IBM\Notes, and so on.
In loginscript make sure, that for every user the right Folder is mapped as "D:".
That way it should be possible to start Notes concurrently in different sessions.

How to debug VB.NET windows service without Visual Studio

I have the source code of an windows service which is written in VB.NET
I came through various methods to debug this service using development environment (Visual Studio). But the challenge is, I need to deploy it in one of our servers as other application on that server need to access it. The server doesn't contain any development or debug tools. I am not allowed to install visual studio in it.
Is there any other way to debug the windows service on this server?
My intention is to understand the method call hierarchy, as this is a very complex code and I didn't write it. It has a very complex architecture and it is not possible to track the data flow only by looking at it.
If the only restriction is you can't install Visual Studio, I'd suggest you get the Remote Tools for VS 2012, which don't even need to be installed to the server, just a machine with a share accessible from the server. Then follow the instructions.

How do I Execute Visual Basic Exe and Crystal report in LAN

Hi I have a Visual Basic Project Exe which runs fine on a Single Machine i Want it to be Execute for Multi User in LAN. I Have Used Crystal Reports in My Project and database is MS Acess. Please Help me how run the Project in LAN..
A VB EXE is a client architecture which usually needs installing on each client machine using it. The code in the EXE could/would normally then connect to external shared, singular resources over a network (such as databases, reporting servers etc.) but the actual EXE itself would typically be duplicated upon each client computer.
If you need all the users to open the exe and have it always run on the same machine, then you could create client shortcuts or use a script with a CreateObject("application.NameHere","serverToRunAppOn") call &/or modify the DCOM settings for the app through the dcomcnfg tool...
However I'd sugguest instead re-evaluating your architecture. Possibly turning your app into a better practice web-based or MS Access shared MDE+MDB solution for clients to connect to.

Run an executable when a web address is called

I'm trying to find a way to run a dos executable when called by another server.
It's hard to explain sorry,
So I have a windows server 2008r2. On it is a dos exe that I need to run.
I also have a linux ubuntu server that hosts some SQL and web pages (apache).
Users update a table in the linux box, and when they do I need to run a dos exe on the windows box.
I don't want to use scheduled tasks on the windows box, because updates need to happen at the moment the data is changed in the linux box with little delay.
Any way anyone can think of that the linux box can 'call' the windows server to run the exe?
Thanks :)

IIS connecting to LocalDB

Is there any way so IIS could connect to LocalDB without using the NT SERVICE\NETWORK SERVICE user account.
This account has not suitable permissions. I'm looking use some other default account or is there some way that I can use the NETWORK SERVICE account without changing permissions?
You should use Shared Instances feature of LocalDB. These two posts on Using LocalDB with Full IIS should give you more information. Especially the second part seems relevant, but the first one contains some context as well.
(note: the original links are no longer available, using archive.org instead)
Part 1: User Profile
Part 2: Instance Ownership
Original (non-working as of March 2019) links:
Part 1: User Profile
Part 2: Instance Ownership
In case the links disappear again, I am copy-pasting solutions from the article for easier access:
Post 1:
The problem we're facing is that the user profile needs to be loaded. That shouldn't be hard since each IIS Application Pool has an option called Load User Profile that can be found in Advanced Settings section. Unfortunately things got slightly more complicated in Service Pack 1 for Windows 7. As described in KB 2547655 enabling loadUserProfile is not enough to fully load user profile, we also need to enable setProfileEnvironment. This requires editing applicationHost.config file which is usually located in C:\Windows\System32\inetsrv\config. Following the instructions from KB 2547655 we should enable both flags for Application Pool ASP.NET v4.0, like this:
<add name="ASP.NET v4.0" autoStart="true" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
</add>
Having completed that we restart the Application Pool to make sure the new settings are applied and run our Web Application again.
Note from my side: Just find "applicationPools" tag in that applicationHost file and update those two variables to true, so it looks like this:
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
That's it, save the file and restart IIS pool.
Post 2:
The Problem of the Private Instance
As we can see we are facing the following error:
System.Data.SqlClient.SqlException: Cannot open database "OldFashionedDB" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.
This time the error is quite clear. LocalDB was started and the Web Application was able to connect to it, but the connection was then terminated due to login failure. The ApplicationPoolIdentity account for the IIS application pool (in this case IIS APPPOOL\ASP.NET v4.0) couldn't login to LocalDB instance because the database specified in the connection string (OldFashionedDB) wasn't found. How odd, since connecting from Visual Studio with the same connection string succeeds!
How is it possible that Visual Studio connects to LocalDB just fine, while the connection from Web Application fails? In both cases the connection string is the following:
Data Source=(localdb)\v11.0;Initial Catalog=OldFashionedDB;Integrated Security=True
The answer is that there are two different LocalDB instances here. Unlike SQL Server Express instances, which are running as Windows services, LocalDB instances are running as user processes. When different Windows users are connecting to LocalDB, they will end up with different LocalDB processes started for each of them. When we connect to (localdb)\v11.0 from Visual Studio, a LocalDB instance is started for us and runs as our Windows account. But when Web Application, running in IIS as ApplicationPoolIdentity, is connecting to LocalDB, another LocalDB instance is started for it and is running as ApplicationPoolIdentity! In effect, even though both Visual Studio and Web Application are using the same LocalDB connection string, they are connecting to different LocalDB instances. Obviously the database created from Visual Studio on our LocalDB instance will not be available in Web Application's LocalDB instance.
A good analogy to this is My Documents folder in Windows. Say we open Visual Studio and create a file in our My Documents folder. Then we login to the same machine as a different user and go to My Documents folder again. We won't find the file there as My Documents of the second user and our My Documents are two different folders. Similarly LocalDB instances (localdb)\v11.0 owned by two different users are two different processes with two different sets of databases.
This is also the reason the Web Application was able to connect to LocalDB from IIS Express. Just like LocalDB, IIS Express is a user process. It is started by Visual Studio and runs as the same Windows account as the Visual Studio process. Two different processes running as the same Windows account (Visual Studio and IIS Express, both running as our Windows account) connecting to (localdb)\v11.0 are connecting to the same LocalDB process, also started as the same Windows account.
Possible Solutions
Understanding the nature of the problem brings multiple approaches to solving it. As different approaches have different tradeoffs, instead of prescribing one solution, below I presented three approaches that seem most viable to me. My hope is to hear from you about the one that worked best for you! Here is the list:
Approach 1: Run IIS as our Windows user
Approach 2: Use LocalDB Shared Instance
Approach 3: Use full SQL Server Express
Let's take a closer look at each of them.
Approach 1: Run IIS as our Windows user
If different user accounts are the problem, why not try to run our Web Application under our Windows account? Web Application would connect to the same LocalDB as Visual Studio and everything should just work.
Making the configuration change is relatively easy, just start IIS Manager and find the right Application Pool:
Open Advanced Settings screen (available in the context menu):
Click the little button in the Identity property to bring up the Application Pool Identity screen:
Starting the Web Application again will confirm that the problem is solved:
What are the drawbacks of this approach? Of course running Web Application under our account brings certain security risks. If someone hijacks our Web Application they will be able to access all system resources our account can. Running the Web Application as ApplicationPoolIdentity provides additional protection since ApplicationPoolIdentity accounts have very limited access to local system resources. Therefore I cannot recommend this approach in general, but when used with care it is a viable option in some cases.
Approach 2: Use LocalDB Shared Instance
We could also use an instance sharing feature of LocalDB. It allows us to share a LocalDB instance with other users on the same machine. The shared instance will be accessible under a public name.
The easiest way of sharing an instance is to use SqlLocalDB.exe utility. Just start an administrative command line prompt, and type the following command:
sqllocaldb share v11.0 IIS_DB
It will share the private LocalDB instance v11.0 under the public name IIS_DB. All users on the machine will be able to connect to this instance, using (localdb).\IIS_DB as a server address. Note the . before the instance name, indicating this is a shared instance name. We should replace the connection string in our Web Application with an updated one:
Data Source=(localdb)\.\IIS_DB;Initial Catalog=OldFashionedDB;Integrated Security=True
Before the shared instance can be used by the Web Application we need to start it and create logins for the ApplicationPoolIdentity. Starting the instance is easy, simply connecting to it from SQL Server Object Explorer will start it and keep it alive. Once we are in the SQL Server Object Explorer we can also create the login for ApplicationPoolIdentity. We could use the following query:
create login [IIS APPPOOL\ASP.NET v4.0] from windows;
exec sp_addsrvrolemember N'IIS APPPOOL\ASP.NET v4.0', sysadmin
This script gives full administrative access to our LocalDB instance to the ApplicationPoolIdentity account. Whenever possible, I would recommend using more limited, database-level or even table-level permissions.
Now we can run our Web Application again. This time it should work just fine:
What are the drawbacks of this approach? The main one is that, before Web Application can connect to the shared instance, we need to make sure the instance is started. For that to happen the Windows account that owns the instance must connect to it and the connection must be kept open, or the LocalDB instance will shut down.
Approach 3: Use full SQL Server Express
Since full IIS runs as a service, maybe using traditional, service-based SQL Server Express is the right approach? We could just install SQL Server 2012 Express RC0 and create the OldFashionedDB database in it. We can even use our brand new SQL Server Data Tools to do it, as it works with any SQL Server version and edition. Our connection string would have to change to:
Data Source=.\SQLEXPRESS;Initial Catalog=OldFashionedDB;Integrated Security=True
Of course, just as in the previous case, we would need to make sure the ApplicationPoolIdentity account has access to our SQL Server Express instance. We can use the same script as previously:
create login [IIS APPPOOL\ASP.NET v4.0] from windows;
exec sp_addsrvrolemember N'IIS APPPOOL\ASP.NET v4.0', sysadmin
After that, running our Web Application brings the happy picture again:
What are the drawbacks of this approach? Obviously we lose the benefits of using LocalDB. Installing SQL Server Express may take more time than LocalDB, and there may be some machine cleanup necessary for it to succeed. SQL Server Express Setup can be blocked by problems like corrupt WMI database, polluted registry or components left by SQL Server or Visual Studio CTPs and Betas. And SQL Server Express will continue running in the background even when not needed, as services do.
Other options
There are other approaches of using LocalDB under full IIS that are not covered here. We could embrace the Web Application's private LocalDB instance and communicate with it through the Web Application by executing T-SQL scripts from ASP.NET code. We could also use AttachDbFileName option of ADO.NET connection strings and use a database file (.mdf) that would be attached to both our LocalDB during development and Web Application's LocalDB for debugging. I tried both I found them too cumbersome to discuss further.
Based on the answer from #KrzysztofKozielczyk.
I originally posted an answer here:
https://stackoverflow.com/a/62810876/3850405
After following this I verified that Load User Profile was set to true for my Application Pool and then set setProfileEnvironment to true in applicationHost.config. I did the last part by editing applicationHost.config located at:
C:\Windows\System32\inetsrv\config\applicationHost.config