Why might one app connect to SQL backend OK and a second app fail if they share the same connectionstring?

StackOverflow https://stackoverflow.com/questions/11311850

  •  18-06-2021
  •  | 
  •  

Question

Trying to figure out a SQL connection error 26 in our app.

We've got two closely related apps Foo and FooAddIn. Foo is a Winforms app built in VS2010 and runs fine and connects fine to our SQLExpress back end.

FooAddIn is an Outlook AddIn which references Foo.exe and connects to the same SQL Express instance. Or rather, it doesn't connect, instead reporting:

A network-related or instance-specific error occurred while establishing a connection
to SQL Server. The server was not found or was not accessible. Verify that the 
instance name is correct and that SQL Server is configured to allow remote 
connections. (provider: SQL Network Interfaces, error: 26 - Error Locating 
Server/Instance Specified)

Now, both apps share the same connectionstring and we've verified they really do share the same connectionstring.

At this stage we're just testing from within the same developer machine, so the apps are on the same machine, going via the same VS2010 IDE.

So a lot of the advice online for this error doesn't apply because the fact that Foo connects through to SQL Express tells us the database is there and available and can be reached.

What else is there to check? One thing is that Foo and FooAddIn are running different runtime versions of System.Data (v2.0.50727 and v4.0.30319). Could that be a factor?

Was it helpful?

Solution

Resolved: it's merely a Firewall issue after all


A colleague pointed out that our FooAddIn Outlook Addin will run in a different security context from the Foo Winforms app.

We checked the firewall and sure enough a whole bunch of a blocked connections from Outlook.exe were listed.

So, even though they were on the same machine, and their connectionstrings are identical and they're both VS2010 applications the Firewall sees them as nothing like the same thing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top