.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

how to use Application variable in a App_code file

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net
Hi I created a variable in VB.Net's Global.asax file Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Application("AppRootURL") = HttpContext.Current.Request.ApplicationPath End Sub Now I want to use this variable in all files where I want to use. I have App_code folder in that I have some files. In a particular file I want to get this app variable but I am not able to get . Getting this error only when I want to use App Variable in App_code/xyz.vb file. Reference to a non-shared member requires an object reference. ` Any work around for this ?? Regards, Sriram

View Complete Post

More Related Resource Links

New off line application working with sdf file. Need advice


Hey Folks

I am working on a project currently where I need to get data out of a 3rd party vendor's software that uses a .sdf file I looked this up and its a SQL CE file. I was hoping to just link to with with access but thats apparently not going to happen. I need to link to the database extract data from it to a csv file for later use. I also and most important I need to get the data from it and create a report that can be printed while on a customers site that my or may not have web access so I need for this program to be on and off line. I had my webapplication that I have been working on open and was able to bring up the sdf file under the server exploere however I can't seem to get anything out of it when I try to do grid views or detail views errors out.

Can I use one of Visual Studio projects to create this sort of applicaiton if so what would be the best approach. I would love to get an access odbc driver since office is allready installed on the employee's laptop's



Read Excel file from Web Application (C#)



I have a web app where user uploads a file.

File is saved in server locally and I want to read some data from it.

Currently my development  server has office 2003.

So do I need office 2007 in order to be able to  read an excel from office 2007 ?

What are other requirements  ?

I tried a test, using

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook wrkBook; // = new Microsoft.Office.Interop.Excel.Workbook();

wrkBook = excelApp.Workbooks.Open(@"C:\www\excel_files\b.xls", ....);

But When trying to open the file I get the error:

Exception from HRESULT: 0x800A03EC

So I'm wondering what I'm missing.


An example of packaging web application containing database upgrade SQL file

A few months ago, we have a blog talking about extending the web publishing pipeline to package database project deployed SQL file.  In this blog, I'll show step by step example of packaging web application with SQL Server database upgrade SQL file using Visual Studio 2010.  This way, we can generate a web package with incremental SQL script to certain database version.  The scenario may help distributions of a web upgrade package which needs to be installed on many different locations, each with their own SQL server database.   1. Create a Web Application Project 2. Add a new "SQL Server 2008 Database Project" to the solution 3. Prepare a development database, such as my test1 database as the following: 4. Right click our...(read more)

is application variable is overwritten?



in my website i have stored logged in user name into one application variable;

ie;Application["uname"]="Sam"; just like this.

where "sam" is user name taken from table when he logged in.My doubt is that,is another person is log in at same time in different computer then the application variable is overwritten or not?

is there is only one application variable is created for every user?


for each user different instances of same variable is created ?

pls,help me....

how to consume the dll file which is registered in GAC, into my asp.net web application



i have created a strong name key to my dll file...and then i have added it to GAC.

In general, to add a .dll file in the solution explorer, right click -> add reference...

How should I refer the dll file registered in  GAC



using application configuration file in AppData special folder

Hi! So I understand it is a best practice to save the application configuration files under the AppData folder, rather than in Program Files, since UAC will restrict write acces to the Program Files folder, which is fine. Now, saving the configuration file to another location is no problem, using the SaveAs method. However, when I load the application, I expect some settings to be read. From what I know, this is done either using direct calls to the ConfigurationManager class, either initializing a Configuration object. For the first case, a example is this: if (ConfigurationManager.AppSettings["Title"] != null) { this.Title = ConfigurationManager.AppSettings["Title"]; titleTextBox.Text = ConfigurationManager.AppSettings["Title"]; } For the second case, I would use it like this: Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); string setting = config.AppSettings.Settings["Title"].Value.ToString(); So, if the application runs in the Program Files folder, an exception is thrown when I save the file. However, if I save the file using SaveAs and save it to AppData folder, obviously, when loading, the settings are not loaded from the AppData folder, but from the configuration file existing in the Program Files folder. One way to solve

App_Code file icons

 Can anyone tell me why some of the xxx.vb class file icons have a 'vb' in the upper left corner of the icon and some have 'three little squares' in a reverse 'L' shape in the upper left corner of the icon ?

Import Error: Could not process the file Documents/Application Deployment.mht as a Single File Web P

Hi there everyone, Version: Windows Sharepoint Services 3.0 with Cumulative Update June 29, 2010 applied. I am having issues importing an exported site into a different domain. I've overcome most of the issues and actually got most of the site to import, however, the import process get's stuck on import a Single File Web Page document from a document library. I believe the original cause of this error is http://support.microsoft.com/kb/980079 The issue I face now is, I already have a large number of .mht files in my document library which I do need to import into the test environment (or that I might need to restore in a DR scenario). Does anyone have any information on either: forcing the import commmand to "on error resume next" (ie. not stop processing when it encounters an error) fixing the already corrupt .mht files in the database easily The error text from the import command is: Error: Could not process the file Documents/Application Deployment.mht as a Single File Web Page document. at Microsoft.SharePoint.Library.SPRequest.CreateOrUpdateFileAndItem(String bstrUrl, String bstrWebRelativeUrl, Guid& docId, Object varDoc, Int32 docLength, Int32 exists, String bstrCreatedBy, String bstrModifiedBy, Int32 iCreatedByID, Int32 iModifiedByID, Int32 iVersion, Object varTimeCreated, Object varTimeLastModified, Object varProperties, String checkInComment, Int3

use DLL application config file

Hello All, I develop a multi layer application with windows form project and multiple class library. In my "Common.dll" (where I put common application fuctionality and use it in all application hat I develop), I have encapsulated logging capabilites using the Enterprise Library 5 logging facility into a DLL and added an app.config with all the pertinent loggingConfiguration XML as produced by the Enterprise Library Configuration Editor. When I run application I get Error and can not use Logging capabilites of my Common.dll. But when I copy App.config content into app.config of windows form project everything works fine. Also I have same problem with hosting services in my "DataAccessLayer.dll" using app.config that add to DLL. Again when I copy App.config content into app.config of windows form project everything works fine. Absolutly I want keep setting in seprate configuration file and do not marge them into same file. Is it possible?

Foreach File Enumerator - Use Variable to Set FileSpec Property

Hello All: Can anyone give guidance on how to set the mask for a Foreach File Enumerator programmatically? I have a DB that has a list of masks. I am retrieving that into an ADO recordset. For each record I retrieve the value into a variable. I would like to look at a directory and move all files that begin with the chars for each item in my recordset variable. TIA - Tom

Sdf file doesn't update once the application close

     i have configured for data sync setup using configure data synchronization wizard, then deploy the application in emulator. while run the application the data has synched back and forth from client to server on two way sync.  once application get closed the sdf.file is only having  existing data which is same as we got end point of configuration. we can view the updated data while run the application. but we restart application we didn't have the updated and newly inserted data . i don't know what i missed in config. it would be great help if anyone guide me.

how to periodically update database file of my wpf application?

Hi, I have a WPF Windows application which we distribute to our clients. The application consists of some database table which changes every month. eg. the application users a  exchange rate table which is valid for one month. What is the best approach to update the data in these table. Please note that the whole application is not changing but only the data in it changing. Please guide me with some options how I can achieve this task. Thank You. Mohamed Ziyad

JS script file path screwed up after deploying MVC application

Hi,  I am relatively new to MVC, after deploying my MVC application as per Haack http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx i seem to have got a new problem. My Jquery doesnt seem to get recognized. I get "object doesnt support this property or method " at this line "jQuery(document).ready(function() {" i have tried all sort of things including changing the js script file path to relative and absolute, setting base tag etc. Kindly advice if the above method of deploying is right and if that is what is causing the issue and if there is some other way to handle the .mvc requests.   Thanks and Regards, Muzammil Ahmed

Logging Application Block -- A GUID might be prepended to the filename of the log file



Here is my problem definintion.

I am using Microsoft.Practices.EnterpriseLibrary.Logging.dll 4.1 version. It is found that

"A GUID might be prepended to the filename of the log file".

I did some googling and came to know that this is known issue from the following link


So how to resolve this. Is there any cleaner approch that i can use.

Please do reply.

Thanks in advance.

.tmp file created after process crash when application upgraded to 2.0

After upgrading an asp.net application to 2.0 from 1.1 I am receiving a large 100+MB .tmp file in C:\Temp on the web server when the w3wp process serving that application crashes. If you open the file it looks like it is some sort of dump file. Any ideas how to turn this off. I know what is crashing the application and process. Any help is appreciated. Thanks

How would I set a Enviroment Variable on Several remote Machines from one Application

I think my title covers the high level, but for indepth; i need to be able to connect to a machine through and ip and set a enviroment variable, i have over 60 machines in different states all on one network that i need to do this for as well as someother things for the machine. currently this is being done through a PCEXEC command in a batch file they want more control on how this operates. I just really have no idea where to even start looking for the enviroment variable change(setting one on a machine that the app is running is simple we all know that. but on a external machine im lost) on a remote machine. any one have any ideas.
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