Skip to content

Loading an Embedded Resource XML File into a Steam for a web application over IIS

July 3, 2012

Today I had been very busy working out as to why the web application over IIS had been taking way too long, I found out after using the tool ANTS Profiler that the default.aspx page was taking too long to load, and was in fact when reading the XML file for configuration that it may be in an infinite loop. In fact it had been, and the XML file couldn’t be read, whilst running on the local machine can.

Turns out that you need to embed the resource file for the XML as an embedded resource for use as a stream using the method GetManifestResourceStream like so: –

Assembly assembly = typeof(PortalConfiguration).Assembly;
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(“ProjectRootNamespace.PortalConfiguration.PortalConfiguration.xml”);

This only works when you set the Project ROot Namespace correct, you can check by clicking on the menu Project and Properties and checking the value of Assembly Name and plug this into the above ProjectRootNamespace.


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: