.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
ASPEvil
Ashutosh Jha
Jean Paul
satyapriyanayak
SP
Post New Web Links

Not able to read Config File data in Windows Service

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :.NET Framework
 
While I'm trying to read connection string which is in App.Config file I'm getting error like "Object reference not set to an instance of an object." string strconn = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"].ToString(); For the windows service where I need to keep app.config file and how to integrate that config file with the windows service exe file. Thanks in advance.


View Complete Post


More Related Resource Links

Writing the windows forms data to an HTML file

  
I have a windows forms application ready now i need to transfer data from the windows forms to the web and to do this i need to write an HTML file that contains the form data, i mean the data contained in the form should be written to an HTML file to be submitted and this HTML file should be generated on the local PC. I have the code for the HTML file but how can i write this HTML file with the data values contained in my windows forms. Please give your suggestions. Best Regards, Syed

Documentation on impersonation of Windows LiveID with data service?

  
Hi There, I'm not finding any documentation on impersonating a Windows LiveID over a WCF data service. I can find documentation on Windows Auth. For example, this article is great, but its first step is "Configure Your Service to Use Windows Authentication": http://geekswithblogs.net/manesh/archive/2009/04/23/setting-up-wcf-to-impersonate-client-credentials.aspx. I'm not sure how to do this when I'm working with the LIVEID. Alternatively, and even preferably, if there's a way I can manipulate the connection string the data service is using from the WCF endpoint, that would be ideal. I need to grab some info about the user in the Silverlight app that's using the data service, and somehow impersonate that user. The user is a Windows LiveID, which is what I have hard-coded in my connection string in my web.config. Thanks!  Web: http://invoc.net

Read Binary Data which is nothing but a Zip file and unzip through SSIS 2005 SP2

  
Hi ALL, I need some help in developing a task. I have a source database which is Oracle and it has a ZIP file stored inside the database in Binary format. When I move this data into the sql server 2005 database I get the data as binary data. Now the task begins with SSIS, I need to read the binary data which gives us a zip file and then unzip this zip file and read the XML data which is present inside the Zip file. I beleive some one might have already developed this task can you share the solution with us. Note: As this has to be moved into production I dont have permission to use third party tools like Cozy roc or install winrar.exe and simpy calling this exe from the execute process task in SSIS.  Raju

how to get config data from config file for CustomFormAuthentication dll

  
I have done cutomization sql report to form authentication. I need to get some config data/string from config file. I added one app.config, but can't get data from this config file. What is wrong with me. I used below code to get data inside c# code , but it can't get it. string ServicetURL = ConfigurationManager.AppSettings["ServiceURL"]; config file: Microsoft.Samples.ReportingServices.CustomSecurity.dll.config   <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <configuration> <appSettings> <add key="ServiceURL" value="wwww.name.com" /> </appSettings> </configuration> thanks Gary  

How to read an Excel file and show data from 2 columns

  
Hi,I have an Excel file called Products.xls .I have Columns A and B, with the titles NAME and QUANTITY.The name of the sheet is SHEET1.The file has about 40 lines.How do i show these data on a Gridview or Listview ?Thank you.

Error reading .config file in Windows Forms app - Access is denied

  
I'm attempting to read a connection string from a .config file in a Windows Forms app on a test laptop. A previous version of the application worked just fine, but now I get a configuration exception thrown - "Configuration system failed to initialize." The inner exception message says - "An error occurred loading a configuration file: Access is denied". The user I'm logged in as is in the Administrators group and there's no obvious problems with the config file. The same config file works just fine on my dev machine so it's not an issue with ordering of the XML. Any ideas would be greatly appreciated.If a response to your question is helpful or answers it please mark it as such!

Error reading .config file in Windows Forms app - Access is denied

  
I'm attempting to read a connection string from a .config file in a Windows Forms app on a test laptop. A previous version of the application worked just fine, but now I get a configuration exception thrown - "Configuration system failed to initialize." The inner exception message says - "An error occurred loading a configuration file: Access is denied". The user I'm logged in as is in the Administrators group and there's no obvious problems with the config file. The same config file works just fine on my dev machine so it's not an issue with ordering of the XML. Any ideas would be greatly appreciated.If a response to your question is helpful or answers it please mark it as such!

data view web part - read and write using web service

  
Hi I am looking for an example on "Data View Web Part" in WSS 2010 to read and write data from a web service that I have written and then update the database. or if you have a any better way of doing this function of reading and writing data to and from "Data View Web Part" in WSS 2010. Thanks heapes in advance. Kind Regards,  sword

How to send binary data ( ogg audio file) using a web service?

  

Hi folks, I would appreciate any help or guidance on this topic:

How can I receive binary data (specifically an ogg audio file) using a WCF4 service?

The general idea is to define and host a WCF service inside IIS that returns an audio file (ogg file)

I have read some info related with using ByteStreamMessageEncodingBindingElement class to achieve this, also I read some topic related on using MTOM to attach a binary file. It seems that it can be several ways or approaches to achieve this.

So any guidance on the themes and/or examples for the better way to solve this point would be very appreciated.

Thanks in advance.

Carlos


cortega

Using XMLReader and XMLWriter to read and write to a config.xml file

  

I have a c# program, and I have created an initialization.xml with some attributes.  One of the attributes is an output directory location that the user enters.  I want to be able to open the init file and write this directory path to the outputLocation attribute of the init xml file.

I know how to read xml files using XMLReader and create and write new XML files with XMLWriter, but not sure how to go about open an existing file, moving to a specific attribute, and writing the value to it.

I am assuming this is pretty straight forward.

 

Thanks


Add Service reference not updaing the client apps web.config file in .Net Framework 4.0

  

Hi Team

I am doing some experiments with WCF on .Net 4.0. I have created a service in 4.0 and add a new empty web application to consume my Service. When i added a service reference from the IDE, i can see the web.config file is not updated with the Servcie end points. How do i solve this issue?

My web.config in the client looks like this after adding the service reference.

is it necessary to have a config file when creating proxy of WCF service

  
Sign In to Vote Hi to all,

i created a service.cs file with the following code then tried to create proxy using svcutil comand.... but it gave error "not able to obtain metadata". After some web search i found i need to add a meta endpoint to the service. so i copied and pasted the code... now svcutil works and creates the proxy.cs. BUT ITS ALSO CREATED A CONFIG FILE. i want to know Do i really need this config file?? if yes then can u please describe its content to me...i will be highly thankfull to you.

INITIAL CODE:

using System;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace Service
{
 [ServiceContract]
 interface Iservice
 {
	 [OperationContract]
	 string getMyDeals();
 
 }


 class Service : Iservice
 {
 public string getMyDeals()
 {

	

Manual change to "applicationSettings" in app.config file are not read by the application.

  

Hello,

Okay...This Application Settings stuff is driving me nuts.  Something conseptually so simple should not be this hard to get working.

Here is my

I have a .NET 4 application in which I generated a web reference from a web service wsdl.

I see that it creates an endpoint property in the app.config file which corresponds to a settings class that is autogenerated.    I compile my release code and copy the executable and config file to a local drive.

By default, the url points to the endpoint that was added by the designer.

Now, I want to change my application configuration to point to the production version the the webservice.

To do this I thought all I had to do was change the value in the app.config file.  However, the application never reads from the config, it's always taking the default setting compiled into the settings class.  I'm at a loss as to why this is happening. 

I have search through this forum and there are so many different posts on application settings but all I want to do is change the config file manually without having to recompile.   I'm not doing any runtime settings modifications. 

What if down the line we change the alias to the web service hosting the service.  I can't imagine Microsoft really expects us to have to rec

I want a web service which will pick the data from sqldatabase and send a xml file for every row of

  

I want a web service which will pick the data from sqldatabase and send a xml file for every row of sql table in output folder.

i.e-if i have 5 records in database then that webservice should return 5 xml document in folder.

Is this possible?

If yes please let me know how can i do this ....

Thanks in advance

Manoj


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend