RazorEngine IsolatedTemplateService is not preventing growth of number of loaded assemblies - appdomain

I am attempting to use the IsolatedTemplateService in RazorEngine 3.2.0.
According to http://www.fidelitydesign.net/?p=473, this should prevent an ever-increasing number of assemblies from being loaded into my main AppDomain.
This doesn't seem to be the case, however. I am using PerfMon to monitor the number of loaded assemblies and each time I execute a template, the counter value goes up.
Repro:
1) Open perfmon and start watching the .NET CLR Loading: Current Assemblies and .NET CLR Loading: Current Appdomains counters
2) Parse a template using the IsolatedTemplateService
Results:
The "Current Appdomains" counter DOES spike up when the template is parsed, and then drops back down afterwards. It does look like a separate appdomain is being created.
The "Current Assemblies" counter just keeps going up. It does NOT drop back down at any time.
Am I reading these counters wrong? Or is the IsolatedTemplateService failing to constrain the dynamic assembly creation to the temporary AppDomain?

Related

VB6 COM+ Out of Memory Issue

We have a ASP.Net web application which runs on .Net framework 4.0.
Architecture is like,
.Net Module --> VB6 COM+ Data Object --> VB6 COM+ Calculation Module
--> 3rd party COM+ Finance Factory (installed COM).
End user uses this application to create contracts by collecting customer details, vehicle details, finance details and calculate multiple parameters in a single calculate button click then submits all the data to another system.
Issue:
Intermittently, it is throwing ‘Out of Memory’ error while calculating the deal (on clicking calculate button on the deal) and calculation is not being completed successfully. This impacts the business.
We found that it is being thrown in the VB6 COM+ Calculation Module -> in a Initialize method.
This method is initializing the third party (installed) COM objects and feeding the necessary data for calculation in xml format (Predefined), immediately getting back the response and ending the subroutine.
We got to know that this error is happening inside this method only and not sure about which statement is causing this. And this happening in Production environment alone. No other (test) environments are able to be replicated.
It is high risk to have any logs over this method and redeploy the code into Production and hence we are unable to have any log information over here. It was an issue since beginning but happens very occasionally but it became frequent since past 6-8 months.
Error message: Sub: Initialize
Error Number: 7
Error Description: "Out of memory"
Environment detail:
Windows 2003 Server SP 2 with 3 GB of Physical memory. Our application COM objects are built with Apartment Thread model and registered within MTS.
We carried out Load test, stress test but still unable to replicate the issue. And hence we are unable to find the root cause as well. We had spent good enough time on this and still struggling.

Questions about DLL load order

As we know, for implicitly linked DLLs of an executable, at load
time, they will be loaded into memory by the loader, and the
loader will calls their entry point to initialize them as well.
This is a linear process - they are loaded one by one, and be
initialized one by one. So the most important thing is the order,
the order affects a lot of things.
Q1: The initialize order can be different from the load order, is
this true ?
Q2: The load order is affected by the import table, is this true ?
Q3: The initialize order of independent DLLs is affected by the
import table - A DLL may be initialized first because it appears
first, is this true ?
"The process is created in a suspended state with the
CREATE_SUSPENDED flag to CreateProcess. Detours then modifies the
image of the application binary in the new process to include the
specified DLL as its first import. Execution in the process is
then resumed. When execution resumes, the Windows process loader
will first load the target DLL and then any other DLLs in the
application's import table, before calling the application entry
point."
I found this important message on the document of Microsoft
Detours. So for Q2 and Q3, yes, it's true. I will do more research
on this topic.

VS2010 vb.NET: System.invalidOperationException: the 'Microsoft.ACE.OLEDB.12.0' provider is not registered at the local machine

Good morning.
I'm in the process of writing a vb.NET forms application that will read in a selection of .xlsX files and import their contents into a SQL2012 database. Because the files are in different folders and are all formatted differently, I'm having to write it so that each folder's contents is handled by its own dedicated module. However, one thing that's common across each folder is the process that I need to go through, which is to open each file, read its contents into a DataTable, carry out any manipulation required (i.e. removing empty rows) and then run a SqlBulkCopy to load the data into SQL before moving the original file into an archive location.
So far, so good. I've written and successfully run three of these modules, but the fourth one is giving me the error that's detailed in the Title of this post - the exception is thrown at the point where I'm trying to open the connection string to the Excel object. Again I stress that I've done this three times before, and each time has been successful.
Also, I've noticed that the exception only occurs when running the code in Debug mode. If I run it in Release mode it works without any complaints.
I'm developing this application in a 64-bit environment (VS2010 on Windows 8.1), but targeting the application to x86. I'm happy to continue writing in Release rather than Debug mode, but I'm curious as to why it works in one but not the other and I'd like to be able to code for both modes if at all possible.
TIA

Is there a way to change referenced library files during processing?

I have a .NET customer framework that functions much like a Workflow. It uses reflection to get a listing of all of the processes it is capable of from a specific folder, and starts them via reflection with a known start point (all of them have a method called "Process"). Since these files are only called to do the processing and not part of the compile... is there a way for me to be able to drop in a new reference library (DLL) for one of the processes that is being updated without restarting the whole process?
Here is my flow...
START
Load list of references
Load work, assign to references
After X Time, refresh references (or
on WCF refresh command being sent)
Is it possible to do this, or do I do I need to actually stop and restart the assembly base to be able to recognized the new reference file?
Yes you can with Assembly.Load but I think you need to look at MEF first.

Nhibernate Profiler - Shows no information other than "session"?

So I am having problems getting NHibernate intergated in my MVC project. I therefore, installed the NHProfiler and initialized it in the Global.asax.cs file (NhibernateProfiler.Initialize();).
However, all I can see in the NHProf is a Session # and the time it took to come up. But selecting it or any other operations doesn't show me any information about the connection to the database or any information at all in any of the other windows such as:
- Statements, Entities, Session Usage
The Session Factory Statistics only shows Start time, execution time, and thats it.
Any thoughts.
Do you have any custom log4net configuration? Just thinking that might be overwriting NHProf's log4net listener after startup. If you refresh the page (and hence start another session*), does NHProf display another Session start? Also verify that your HibernatingRhinos.Profiler.Appender.dll (or HibernatingRhinos.Profiler.Appender.v4.0.dll if you're using .NET 4) is the same one as the current version of NHProf.
* I'm assuming that you're using Session-per-Request since this is a web app.