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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using Other Config File

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :.NET Framework

I have a Class Project and a Application.

the Application use that class as dll.

I want to use the config of Application in my dll or class project.

how to do that ?

Arindam Banerjee

View Complete Post

More Related Resource Links

How to set WebService NameSpace in web.config file?


I am trying to put the namespace value as a key in web.config file, so that when I deploy this on production, I just have to change the namespace key in the config file only, not on all of my webservice cs files. But When I try to browse this webservice after changing this code I get compilation error.


    <add key="NameSpace" value="http://csi-dev-deep/"/>

MyWebService.cs (this code works)

[WebService(Namespace = "http://csi-dev-deep/")]

MyWebService.cs code changed to the following gives compilation error.
[WebService(Namespace = ConfigurationManager.AppSettings["NameSpace"].ToString())]

Compiler Error Message: CS0182: An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type

Your help is highly appreciated.

Thank you.

Problem when using Activator.CreateObject and reading App.Config file

Hello, this is the scenario. I have an application that load at runtime severals dll. these dll are actually "adapters" that wraps calls to web services, database and so on. The app.config of the "main" application stores in config sections all information necessary to each adapter (i.e.Web ServiceURL..) and I have created inside each adapter a class to ready those values the loading at run time the DLL has been implemented by storing all necessary types into a dictionary of generics and when I need to instanciate it I call the Activate.CreateObject and I pass the specific type (I means the name of the Adapter class) The problem is that the adapter class itself is not able to get the config value because ConfigSection has not been initialized. If I write: IInterfaceAdap adapt = new myAdapter() -> I read the config data IInterfaceAdap adapt = (IInterfaceAdap)Activator.CreateObject (type) -> now way to read the data stored in the App.Config. I think that I undertood the problem but I'm not able to find a workaround to read data store in the app.config!! I need help please!!  

"Mixed mode assembly is built against version 'v2.0.50727'.... " issue and use custom config file

Hi, My Winform applilcation has used Microsoft.SqlServer.Management.Common namespace(assembly :Microsoft.Sqlserver.smo.dll/Microsoft.Sqlserver.ConnectionInfo.dll) and developed in .NET 4.0. Problem:Application is throw an exception when it tries to use above assembly reference methods. Full error text is shown below, "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. " Error is resolved when we include "app.config" file with below code, <?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration> But, I need to keep configuration file as "renamed.config" and not to include app.config file as of the project requirement.I have set configuration file as "renamed.config" file using below code, //AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "d:\\reanmed.config" ); I have also included <Startup> element in this "renamed.config" configuration file and removed the app.config file.But it raise me below error, it always expect app.config file with <Startup> element to resolve this iss

Setting maxItemsInObjectGraph in a WCF REST config file???

Hi All, I am trying to create a new WCF Rest service. I used the online VS2010 WCF REST 4.0 template as a base. I have a service up and running and have been testing it using IE/Firefox (currently it is a read only API, so I have no need to post anything back to the service). I have an issue when the number of items being returned is too large, IE give me a "Internet Explorer cannot display the webpage" I turned on tracing and was able to confirm the issue is with the maxItemsInObjectGraph property (defaults to 65536) <Message>Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota. </Message> Using the defualt WCF Web.config file I have no clue how to set this value as it doesnt seem like a standardEndpoint can have this value set, or have a custom binding or behaviour assigned to them (at least I don't know how to set them). Here is the default web.config file the template created. Does anyone know how i can update/increase the maxItemsInObjectGraph property?      <system.serviceModel>    <diagnostics>      <endToEndTracing propagateActivity="true" activityTracing="true"   &nb

How to set anonymous access to IIS 7 from web config file im using asp.net 2.0 C#

HiI have developed asp.net 2.0 website with crystal report now what my problem is whenever i go to crystal report page its by default going to login.aspx or default.aspx though i didt set any login to my asp.net page..I talk with my hosting provider they said that the asp.net impersonate is enable..I think in IIS 7 authentication if i set anonymous access enable, will it work fine?so i need to know how to enable anonymous access from my webconfig ..so please let me know how to do?

Site File Structure, Folders, Learning project, subweb, web.config

I am just learning asp.net.  I purchased an "ASP.Net 3.5 web programming in C#" book, which I like allot.  I am on chapter 3 and want to complete a shopping cart exercise from the book.  I have to create several folders and files.  The exercise has the files and under the root directory and a few folders below that.  I already have a site that I've been learning on.  Can I create a subfolder on my site and put all the files in there?  Like the subfolder is the root of the project.   Here is list of Folders and files... Code/CartItem.cs Code/Product.cs Data/Cars.mdb Images/car.jpg Cart.aspx Order.aspx Web.config ................................ On my website I want to create a subfolder to keep alll the files in, as so... ShoppingCart/Code/CartItem.cs ShoppingCart/Code/Product.cs ShoppingCart/Data/Cars.mdb ShoppingCart/Images/car.jpg ShoppingCart/Cart.aspx ShoppingCart/Order.aspx ShoppingCart/Web.config ................................ Can I have two web.cong files?, one in the subfolder?  Or do I have to use the single, web.config file in the root directory of the site?  Are there any other pitfalls or trouble I might get into setting up my file structure like this?  Anything I should be aware of? Any thoughts or advice would be appreciated. Thanks, Mike   

How to move PrincipalPermissionAttribute from CS file to app.config?

I'm really struggling with the following scenario: I have a WCF service where the methods of the implementation of my service contract are decorated with one, or many, PrincipalPermission attribute(s). For instance: [PrincipalPermission(SecurityAction.Demand, Role = "Administrators")] [PrincipalPermission(SecurityAction.Demand, Role = "MyGroup_1")] public void DoSomething() { //Work done here } [PrincipalPermission(SecurityAction.Demand, Role = "Administrators")] public void DoSomethingElse() { //Work done here } So in this case, method DoSomething(), could be called by users either members of the "Administrators" group or the "MyGroup_1" group. And only Administrators should be allowed to make calls to DoSomethingElse(). My problem is I want to put this in the app.config file, but I can't find any way to do this. How can I "move" these decorations from my CS file to the app.config?  

Not able to read Config File data in Windows Service

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.

SPWorkflowExternalDataExchangeService & SPEmailEventReceiver & config file

Hi, I use SPEmailEventReceiver to raise Event to a WorkFlow using SPWorkflowExternalDataExchangeService, my problem is the workflow is loaded in OWSTIMER.EXE at this time so the workFlow has not anymore access to the Web Config, how can i solve this problem ? Regards, Patrice    

I want add a dll file without using references through config file? what are the possible way to do

i have used this code in config file: what will be the result of that?   <   assemblyBinding> <   startup> <   location allowOverride="true" path="Microsoft.WindowsAPICodePack.dll"></location> </   startup> </   assemblyBinding>

Placing ..... configuration information in a config file other than app.config

Hi, I'm sorry if this question has been asked/answered before on this forum. I have searched both here and on the web in general, but to no avail as yet... I am running VS2010 and .Net 4, so in theory have all the latest versions of everything at my disposal. I have an executable a.exe. This downcalls into a dll b.dll. b.dll wants to send an MSMQ message using WCF. For cleanness (a.exe is a generic service and knows nothing about WCF) I want to define the client endpoint in b.dll.config. However I am finding that WCF is insisting that the information is held in a.exe.config. The exact problem is that when I create my proxy (i.e. the class which derives from ClientBase<T>), I get the message Could not find endpoint element with name 'XXX' and contract 'YYY' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element. From what I have seen I have just described an extremely common problem that people have had with WCF over the years. My questions is basically to find out, given that I have WCF 4 at my disposal, whether there is now a standard approach to this scenario? Things I have tried so far: The obvious one...putting all my config info in a.exe.config. When I do this, everything works file, so I

Writing connection string in web.config file by code or dynamically

I want to write connection string in web.config file of my application by code. If anyone know the way or code just help me..NET,C#,SQL SERVER

Encrypting Sections of the Web.config File

Hello,I have a problem with config section encryption.In Web.config I added protectedData section and I'd like to encrypt network section cos' it contains password<protectedData defaultProvider="MyProtectedConfigurationProvider">  <providers>   <add name="MyProtectedConfigurationProvider"     type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration"     keyContainerName="my"     useMachineContainer="true"     useOAEP="false" />  </providers>  <protectedDataSections>   <add name="system.net/mailSettings/smtp/network"     provider="MyProtectedConfigurationProvider"     inheritedByChildren="false"/>     </protectedDataSections> </protectedData><system.net>  <mailSettings>   <smtp>    <network host="host" password="xxx" port="25"    userName="user" />   </smtp>  </mailSettings> </system.net>Then I execute aspnet_regiis to encrypt that sectionaspnet_regiis -pe "system.net/mailSettings/smtp/network" -app "/mysite" -prov "MyProtectedConfigurationProvider"But I

i make a web site using frame but session is expire Error message is my Config file is attache

i make a web site using frame  but session is expire message is Object reference not set to an instance of an object Description: HTTP 500. Error processing request. Stack Trace: System.NullReferenceException: Object reference not set to an instance of an object at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] in <filename unknown>:0 at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessLoad () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessPostData () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 My Web Config file is<configuration>    <!-- store the database connection info here -->     <appSettings>        <add key="sBook_StoreDBConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Program Files\CodeCharge\Examples\BookStore\BookStore_MSAccess.mdb;Persist Security Info=False" />            </appSettings>  <system.web>  <httpRuntime executionTimeout=&quo

Stupid web.config mistake: Sections must only appear once per config file

Today's stupid mistake comes to you via the web.config file in an ASP.NET 4 Web application project. At runtime, when navigating to default.aspx, ASP.NET choked with this error message: Parser Error Message: Sections must only appear once per config file.  See the help topic <location> for exceptions. Source Error: Line 14:     <location path="default.aspx"> Line 15:         <system.web> Line 16:            ...(read more)

Binding to a custom App.Config file in dotnet 4.0

Hi, I need to resolve Mixed Mode assembly issue using below text in configuration file. <?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration> But, it seems to be work only in APP.CONFIG file. and does not work in custom configurationfile (custom.config).   I gone through the below article: http://weblogs.asp.net/israelio/archive/2005/01/10/349825.aspx still it does not work seems to be work for resolve Mixed mode assemly issue. Please let me know if any one has idea on this.   Thanks, Dhaval Soni    

wants to export pdf file with specified marginn in config file

In my project i wants to display report and export it in pdf format so that i used rdlc but now my requirement is that there are some labels like name,address for it i wants to give some specific margin from left right(x,y) and i wants to give this margin by config file.so that my final question is that anyboby has idea that"how can we set margin in rdlc from cofig file or run time?"if any body having idea other than rdlc file to export in pdf please replay me.
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