473,889 Members | 1,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebService cant access Postgre database

51 New Member
Hi all, could you please help me with my big problem?

I have WebService on IIS. This WebService has methods to control database stored on server.
I am using Postgre database and to access to database I have Npgsql.dll library.
This library is stored in GAC (global assembly cache).

The WebService is not able to open the connection to the database even the connection string is allright, everything seems to be OK. But when the function Open() is called, there occurs an errror "Object reference not set to instance of object" or something like this.

Although, if I access the database with some console application, everything goes well.
Just the bloody WebService :(

Thank you very much for any help.
Zdenek Mach.

ICQ# 173965423
skype: Zdenek_Mach
Mar 21 '07 #1
14 4694
4,871 Recognized Expert Specialist
Welcome to the site. I assume that the problem is in the web service and not IIS. So the question is, what object reference is not set?
Mar 21 '07 #2
51 New Member
I downloaded source code for Npgsql.dll and debug it.
The problem lies in section where sockets are made:

Socket socket = new Socket(AddressF amily.InterNetw ork,SocketType. Stream,Protocol Type.Tcp);

IAsyncResult result = socket.BeginCon nect(new IPEndPoint(Reso lveIPHost(conte xt.Host), context.Port), null, null);

I thought about it and it seems to me that the problem could be in setting of WebService account.
Is it right that if I debug WebService, it all runs under some other account than localhost?
I think it would be somewhere here in all of these accounts and permissions.

Am I right?Tell me please :D
Thx, Zdenek.
Mar 21 '07 #3
4,871 Recognized Expert Specialist
You receive the error when you open try to open the connection, so what information do you have that its to do with sockets? Are you able to test the connection and the sockets separately?
Mar 23 '07 #4
51 New Member
I have found it from source of Npgsql.dll library. I step into Open() function and further found that it ends when there is invokes a method socket.BeginCon nect() or something like this.
Thus I think that if I debug my Web Service, "I have no permimssions to create sockets".

Do yoy understand what I am trying to say?
Mar 26 '07 #5
51 New Member
I also tried to create simple web service and console application and simple create socket and call BeginConnection on it.
Console application works well but WebService ended with same exception "Object reference not set to instance of object".
So thereby I think it would be just in debugger permissions.

Tell me, am I wrong?
Mar 26 '07 #6
4,871 Recognized Expert Specialist
Maybe an example will help:
ASP.NET Web Service
Mar 27 '07 #7
51 New Member
Sorry but this wouldnt help me.
Mar 27 '07 #8
5,058 Recognized Expert Expert
The problem is not that you dont have permission. If that would be the case it would throw some permission exception, not a null reference exception.

As the error say's. Some object that your code is trying to access is set to null.
My guess would be the object you are calling the Open() method on.

Could you perhaps show us the code that gives you the error?
Mar 27 '07 #9
51 New Member
Yes, it could be.
This object may be the Npgsql.dll library which I have in GAC.
I have method to open connection to Postgre database:

private void Open()
// open connection
if (_conDatabase == null)
_conDatabase = new NpgsqlConnectio n(_sConnectionS tring);
_conDatabase.Op en();
Then there is just code from Npgsql.dll and on the end there is

Socket socket = new Socket(AddressF amily.InterNetw ork,SocketType. Stream,Protocol Type.Tcp);

IAsyncResult result = socket.BeginCon nect(new IPEndPoint(Reso lveIPHost(conte xt.Host), context.Port), null, null);

And then exception occurs.
Do you think that it could be in Npgsql.dll in my GAC?
Or could I add this dll to GAC in some wrong way or what?

Thx a lot for any help, Zdenek.
Mar 27 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Nicolae Fieraru | last post by:
Hi All, I am working on a web site in asp which will be hosted on a Windows 2003 server. I use the following code to connect to the database: Set objConn = Server.CreateObject("ADODB.Connection") Set objRS1 = Server.CreateObject("ADODB.Recordset") objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
by: Zlatko Matić | last post by:
Is it possible to use Access as front-end for POstgreSQL and how ? What about Access Projects (.adp) and PostgreSQL ?
by: Trygve Lorentzen | last post by:
Hi, I don't know if this is a stupid question, but I observe that my webservice is created for each call to a webmethod. More precisely an instance of the webservice class is created for each call. This makes the InitializeComponent() method run for each method call and seems to really slow things down. Can I keep the webservice object running after a method call? Trygve
by: kenneth fleckenstein nielsen | last post by:
Hi guru's It runs ok on my developmaschine, and on the test server that i've set up. but fails after installing on the customers server. I made a XML webservice that does these steps: a) access a db for updating ( fails on client ) b) saves some associated files (DIMES/SOAP) ( not testet outside development ) c) writes a log file ( fails on client ) I think a and c has to do with setting ISS up correctly on the customers server.
by: kamig | last post by:
Hey! guys i have this annoying question i have upgrade my webService project from visual studion.NET 2003 to 2005 but the problem is tht i cant access my webService directly from iis mmc by click the .asmx and selecting browsing in old days of .net 2003.....it gives an error like that user initiated the asp.net process should have access to iis metabase....with Microsoft site i download mataacl.vbs with which i try to add my username say...
by: Sakalicek | last post by:
Hi all, can you please help me? I have Web Service that should do some things on Postgre database. I am using Npgsql.dll to provide functions to make connection to the database. But I am not able to make this connection. I tried to step into the Npgsql source and found out that there is a problem when Socket socket is created. I thought about it and got an idea that it could be in ASP privilegies. I suppose that aspnet_wp.exe process...
by: nilart | last post by:
Hi, I have an installer application (Installshield) which installs postgre DB programmatically on windows: I have a requirement where postgre DB is expected work after upgrading OS from windows XP to Vista However once I upgrade to vista somehow ./postgre windows user's password is chnaged or not working If I try to start service Postgre SQL database it gives me "Logon failure" If I manually set password & start a sevice it comes up...
by: prajiv | last post by:
Hi, Pls guide me in synchronizing data from PostGre to Cache. i.e if we update in one database the other database must automatically get updated.I dont want to use the Tool ,I need the code for it 2 update from Postgre or from cache.
by: freeskier | last post by:
Hello, Sorry for the newb question; I've spent a good amount of time trying to figure this out. I am fairly new to the Postgre world. I am currently in the process of upsizing several MS Access apps to a single PostgreSQL system; I will continue to use Access as the frontend. I have duplicated the table structure in Postgre and have successfully connected Access as a frontend to view data. I am having trouble inserting a record into...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.