Remote Debug with Amazon Web Services (EC2) and c# Windows Service/WCF - c#

I have a Windows Server 2008 R2 in the Amazon EC2 cloud. I would love to be able to debug my C# Windows Service or WCF Service that is running on that server from my desktop in my office.
In the past we got around it by installing Visual Studio on the server in the cloud, but we use remote debugging for our local servers, so I was hoping there was a way to make it work in the cloud.
Has anyone out there accomplished remote debugging to the Amazon cloud without a VPC/Domain in the cloud?
Any suggestions or solutions would be most appreciated.

There isn't anything different about remote debugging against an EC2 instance than there is about remote debugging against a local server EXCEPT firewall configuration...
I would recommend setting up a VPN connection to the EC2 server instead of opening up firewall ports (PPTP is quick and easy).
If you would rather open firewall ports I "think" you will at least need the following (untested):
TCP 139, TCP 445, UDP 137, UDP 138 (all related to DCOM)

Another thing that always causes issues for me on EC2 instances is not passing the /hostname parameter to msvsmon. msvsmon likes to default to the internal hostname and will startup showing something like "listening on 'ip-1-2-3-4.us-west-2.compute.internal", which means it will ignore attempts for connections from Visual Studio clients that think they are talking to 'ec2-7-8-9-0.us-west-2.compute.amazonaws.com'. To fix this, get the full public DNS name or public IP of your EC2 instance and then launch msvsmon.exe as:
msvsmon.exe /hostname ec2-7-8-9-0.us-west-2.compute.amazonaws.com
Then in Visual Studio:
Tools-->Attach To Process
Set Transport to "Default"
Set the Qualifier to whatever you passed for a hostname when you launched msvsmon.exe

Related

NancyFx - Find the server over a local network

Scenario: I have a small POS system running in a brick-and-mortar store. The software is running in Windows machines with SQL Server 2008 - 2012 (it varies). There are Android tablets that need to connect to the server in someway to get the data inside SQL Server.
My plan right now is to create some REST Web services using NancyFx and host them as a Windows Service inside the Windows machines. Then the Android tablets will need to connect to the server via HTTP in order to consume the REST API.
I have a problem (perhaps more than one): the network in the brick-and-mortar store is not that reliable and the Wi-Fi signal might decrease for whatever reason.
Question: Is there a way to automatically find the IP or machine name of the server (the one with the REST API) even if these properties change for some reason (unknown network issues or so)?
Yes, the server and the tablets are going to be on the same local network.
it's more of a network problem than programming issue. you must have a DHCP server installed in your LAN. use that to assign an IP to the server with a fixed lease. that way you fix the address of server. clients should preferably connect to that server using its name. since it's a Windows network, name would resolve to the ip address.
that is the simplest solution i can think of

Run C# application without SQL Server Management Studio installed on client machine

I have created a simple login application using the C#.net. I have some basic sql database(I use SSMS). There is name, email and password. I want my application to be usable from more devices (so I can't use localdb). Everything works fine on my pc but when I move to another, where is not installed ssms it shows error 26 - Error Locating Server/Instance Specified. I don't know how exactly to run my C# application without SQL Server Management Studio installed on client machine
I have researched for a weeks so I enable tcp/ip (from sql server manager), also add new inbound rules for tcp(1433) and udp(1434) ports in windows firewall. After that I allow remote connection and add sql server in windows firewall. Also I've tried to install SSMS on client machine but nothing
here are my conncetion strings
this one I tried to solve my problem
Data Source=xxxxxxxxxxxx;Initial Catalog=xxxxxxxxxxx;Integrated Security=SSPI
the other one is my main connection string
Data Source=xxxxxxxxxxxxxxxxxxxxxxx;Initial Catalog=xxxxxxxxxxxxxx;Integrated
Integrated Security = True
The application works fine on my computer, I've installed Visual Studio 2017 and SQL Server Management studio, but when I move to another computer it doesn't work.
Thanks to everyone in advance!!
SSMS is just a Database Management Tool, the actual Database would by SQLExpress or similar. So on your remote host you need to install the latter and set it up correctly in you application to use to appropiate connectionstring to it.
Schema compare your tables from VS and your ready to go.
https://www.microsoft.com/en-us/sql-server/sql-server-editions-express
https://www.mssqltips.com/sqlservertip/5528/installing-sql-server-2017-express/
You dont need to install sql or sql managemment studio in pc where you running your application, but just as your error said "Error Locating Server/Instance Specified", the server where you want to connect, is not accesible, thats means you should open your ports in pc where your sql server is hosted, and also, put your public ip following with that port in your server name in conectionstring, like Data Source=yourserver_IP:8076; tip: make sure your app pc and server pc are in same network.
The reason it works on the same machine is most likely is is that when you go through another machine the connection has to go through a firewall that is blocking access to SQL Server. The default port that SQL Server uses is 1433 and unless you change it on the host machine when you connect from another machine that is the port that is use to connect and you don't have to specify the port. When you connect on the same machine that SQL Server is installed the firewall does not prevent you from connecting. Port 1433 is used for the default instance (The first installed instance on the machine).

Connection string for SQL Server Express on remote computer?

I have a WinForms program I am creating for a friend of mine that uses a SQL Server Express database. Locally, I can connect to my SQL Server Express fine and when I deploy the app to his computer, it works also. I'm having difficulty connecting to his SQL Server Express instance from my machine though (I'm trying to run the program in debug mode in vs2012 but connected to his database). The program uses Entity Framework in case that matters (I don't think it does).
We've setup his firewall to allow my IP address to access his computer and his SQL Server... so I can log in via remote desktop and I can also connect using SSMS from my pc and see all the databases.... but why can't I connect using vs2012? I'm thinking it has something to do with the connection string but haven't found a working solution yet.
Here's what I have tried:
Got these from ConnectionStrings.com:
Server=100.100.100.100\SQLExpress;Database=TestDB;User Id=UserID;Password=myPassword;
DataSource=100.100.100.100\SQLExpress;Database=TestDB;User Id=UserID;Password=myPassword;
Obviously the IP address has changed for the purposes of this post.
Any ideas?
You've used the connection string attribute:
DataSource
There is no such thing, and I suspect it was just a typo (it pays to use cut and paste instead of transcribing). There is actually a space in that attribute, so it should be:
Data Source
Here is a list of things you need to check on the other computer:
Is TCP/IP protocol enabled? Go to SQL Server Configuration Manager -> SQL Server Network Configuration -> Protocols for {instance}
What IP addresses are enabled for listening in configuration manager? Go to TCP/IP properties -> IP Addresses tab
SQL Server browser started
Firewall set properly – you want to enable TCP and UDP traffic on port 1433
Server allows remote connections? In SSMS open properties for that instance and check Connections tab.

Named Pipes provider error 40 when running on IIS 7, but works fine in cassini

I have a web app which connects to a remote sql server over the internet. It accesses via an alias which is configured with the alias name, hostname, port and TCP/IP as the protocol
I can access the db fine from sql mgt studio and from my app when running with the built in web server (cassini) in visual studio 2008.
I have now installed IIS (win7 64bit) and pointed it at the app. when i run the aplication in visual studio, but configured to connect to the local iis, i get the named pipes provider error 40 message. my iis is running as localsystem - but so is IIS on a collauges pc that works just fine. he claims to have done no special configuration.
i don't understand why. identical code. identical connection string. etc. I've disabled my firewall, no avail.
but it works for my colleague - he appears to have the same configuration that i do. i am stumped. does anyone have any ideas?
my sql client configuration now has only tcp/ip enabled.
any help is greatly appreciated.
are you using integrated security by chance? Casinni I beleieve will be using your user when it connects to SQL, however your local IIS 7 will be using the Application Pool identity, which by default your SQL Server won't allow to connect. You can set your app pool to run as Network Service and then see if can connect.
If you aren't using integrated security this would require more thought.
As a total side have you tried using IIS Express? Just as this is the full power of IIS but runs as the current user, which would again help determine if its a user account permission issue.

Difficulty getting Visual Studio 2010 to attach to remote processes

It's been years since I've had such a hard time getting something to work. I'm at home, on subnet 192.168.50.nnn. I VPN'd in to XYZ company office machines that are on subnet 192.168.40.nnn, domain XYZ. I can ping the remote machines, I can net map their drives and copy files back and forth, but for the life of me I cannot remotely debug a C# program running on a machine called R (ipaddr 192.168.40.100, Windows Server 2003, IIS-6) from Visual Studio 2010 on my laptop (ipaddr 192.168.50.10, Windows 7, user XYZ\username, machine name L). I've read every MSDN article I can find, I've checked firewall settings, I unblocked port 135, I have the same user name and password on the two machines, I've tried running msvsmon.exe on R as a service and as an application (advertising itself as username#R), msvsmon has sufficient privileges, but I just cannot attach to any process on R. I can't even get a list of processes on R to show up. If I could pay someone to fix the problem I would, but I wouldn't pay a dime until I saw it working.
[Note: The IP addresses above are illustrative only, not the real values.]
I had a similar problem and my setup looked like this:
Client: Windows 7 x64 on a private subnet 192.168.1.x. Running Visual Studio 2010
Server: Windows 2008 R2 Standard SP1 with a public IP-address
Both client and server where stand alone. I.e. no domains, just workgroups.
VPN connection from client to the server and when I connected the client got the ip 192.168.0.131 and the server 192.168.0.130.
Turned off all firewalls etc. for the VPN connection, created identical users on the client and the server and identical password.
Ping, network shares, etc. working with no problems over the VPN connection. But I got the same error message from Visual Studio: "The Visual Studio Remote Debugger on the target computer cannot connect back to this computer. A firewall may be preventing communication via DCOM to the local computer."
The solution for me was to change the workgroup name on the client to the same one as the server.
After that, everything worked perfectly.
You need to be authenticate on the same domain (or at least there be a trust relationship between the two) as the remote machine. Is the local machine attached to the domain on the other side of the VPN? If not, you cannot debug managed code using remote debugging.

Categories