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

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

Usage Of AppDomain.CreateInstanceFromAndUnwrap()

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
I am attempting to load a dll into a seperate app domain using this code: AppDomain domain = AppDomain.CreateDomain("HardwareAbstractionLayer"); string pathToDll = @"DeviceManagement.dll"; Type t = typeof(DeviceManager); DeviceManager myObject = (DeviceManager)domain.CreateInstanceFromAndUnwrap(pathToDll, t.FullName); I get the error: "Constructor on type 'DeviceManagement.DeviceManager' not found." It appears that the dll uses a singleton pattern and I'm not sure how to use the AppDomain function in that case. Here is the constructor code for the dll: private DeviceManager() { } private static readonly DeviceManager instance = new DeviceManager(); public static DeviceManager Instance { get { return instance; } } I have also tried creating a wrapper class for the singleton, but that does not work either because it says it can't find the constructor in the assembly.  Here is the code for the wrapper class: public sealed class DeviceManagerWrapper : MarshalByRefObject { public DeviceManagerWrapper() { } public DeviceManager DeviceManager { get { return DeviceManager.Instance; } } }    

View Complete Post

More Related Resource Links

Failed to create AppDomain


Recently updated my system to use Visual Studio 2010, and projects will no longer compile. All of them give the error "Failed to create AppDomain." Intellisense does not work either (except for standard HTML tags), and individual pages will also not compile.

Points of note:

  • All sites are hosted on UNC shares (although it doesn't work on a new site created on local drive either)
  • Language is mostly C#
  • No explicit code is creating AppDomain objects
  • Sites compiled fine under both VS 2005 and 2008 both before and after VS 2010 installation
  • Sites compile and run fine from the IIS server on the remote machines (one IIS 6, one IIS 7)

Things I've tried (some obviously shouldn't have any bearing on it, but I've tried just about everything that anyone suggested on any forum I could find, most of which seemed to apply to IIS, not VS):

  • renaming/deleting security.config
  • running caspol -reset
  • re-registering asp.net: aspnet_regiis.exe -ua / aspnet_regiis.exe -i
  • removing VS 2005, 2008, 2010, and then re-installing just VS 2010
  • adding the UNC path to the local intranet zone (internet options control panel)
  • adding the UNC path to LocalIntranet_Zone in the ASP.Net 2.0 control panel (runtime security policy/machine/al

Use Membership but bypass / disable password usage for users


I have an application that does LDAP authentication. The authentication is done on the code behind page of my Login.aspx page. Once the user passes LDAP authentication, a cookie is set and I redirect:

FormsAuthentication.RedirectFromLoginPage(UserName.Text, False)

I would like to setup membership in my application and keep track of some user information. But due to company security requirements, I cannot store user passwords on my application. That must stay on the LDAP server only.

Is there a way to store users but disable password storage on the aspnet_membership table?

AppFabric Cache: Real-World Usage and Integration


Windows Server AppFabric provides a distributed cache for both web and desktop applications. Well show you how to integrate AppFabric caching into your apps, along with some hints for taking advantage of new cache features in the .NET Framework 4.

Andrea Colaci

MSDN Magazine June 2010

CLR Inside Out: Memory Usage Auditing For .NET Applications


Memory usage can have a direct impact on how fast an application executes and thus is important to optimize. In this article we discuss the basics of memory optimization for .NET programs.

Subramanian Ramaswamy and Vance Morrison

MSDN Magazine June 2009

Design: Inspect and Optimize Your Program's Memory Usage with the .NET Profiler API


Developers using .NET often make memory leak tracking a low priority because the common language runtime takes care of garbage collection. What few developers realize, however, is that their objects' lifespans, along with their size and what other objects have been instantiated, all affect how they are cleaned up. Depending on the particular circumstances, these combinations can negatively affect performance, especially over the lifetime of an application. This article presents a way for developers to see memory usage and understand garbage collection using the .NET Profiler API. Along the way, a sample application to demonstrate these principles is built.

Jay Hilyard

MSDN Magazine January 2003

Provisioning: Use Web Services Provisioning to Control Access, Usage, and Billing on Your Site


Building Web Services to provide enterprise-level solutions is only the first step. You need to take care of the infrastructure aspects of your solution as well, including provisioning, billing, security, and reporting. In this article, the author uses the .NET Framework and SQL Server 2000 to design a provisioning system that will take care of all these housekeeping tasks. He discusses the general requirements of a Web Service provisioning system, walks through the implementation, and then outlines various scenarios for putting this system to work.

Chandu Thota

MSDN Magazine December 2002

Usage of Client Access Policy and crossdomain xml for sharepoint 2010>?


Hi Folks,

1.What is Clientaccesspolicy.xml in sharepoint ?

2.What is Crossdomain.xml ?

What is usage of wcf service deploy in sharepoint 2010?

Kindly give me some valuable comments ?


Thank you


Immanuel c


Search Usage Reports Missing for Site


We have Usage Analysis enabled on our employee portal farm.  The SSP in this farm crawls all local SharePoint sites and one child farm.  When we view search and query reports, one of the site collections (in a dedicated web app) is missing.  All other web apps/site collections appear in the search/query reports.  The missing site collection is using the standard search pages and web parts - no customization with the object model that might break usage logging.

Has anyone else ran into this or know the solution?

SSRS - Where are the Sharepoint Report Usage Reports provided by Microsoft



Microsoft provided 3 example reports for Sharepoint report usage. Does anyone know where they are located? I used them about 2 years ago.




Site Collection Usage Summary: No Data Available


Usage analysis processing is enable for my farm in both Central Administration and in the SSP.

I've checked TImer Job Status and the three timer jobs responsible for doing the log analsis are all running.

I've also checked the log file locations and the log files are being generated.

Yet when I browse the "Site collection usage summary" report (SpUsageSite.aspx) I get the following:

No data is available for this report. Usage analysis might have been enabled only recently, or there might have been insufficient usage to result in any values for the report.

My farm is running 2007 Enterprise SP2 (

Can someone confirm if this issue was fixed with one of the CU's that were issues post-SP2?

Site Collection Usage Report Include Outlook?


Hi all,

Does anyone know if the Site Collection Usage Report includes activity that occurs from Outlook? For example, if a user contributes to a discussion board without ever physically touching the site or if the user just reads list content from Outlook, is this included?

ANY help at all is greatly appreciated.


Problems with Usage Reports

I am having problems with the usage reports on our farm.  I cant get to the site collection usage reports or the usage reports in central admin ssp.

I get file not found, so i made the change in the web config for the error and I get:

File Not Found.   at Microsoft.SharePoint.Portal.Analytics.UI.ReportControl.CreateChildControls()
   at System.Web.UI.Control.EnsureChildControls()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Control.PreRenderRecursiveInternal()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Everything has been enabled and the files exist in the correct locations on the server.  I am scratching my head on this one.

All servers are server 2008 x64 enterprise moss 2007 sp2 with august cu.

Re-run WSS 3.0 Usage Analysis Logs


WSS3.0SP2, 64-bit.

The service which runs and collects the log files for the Usage Analysis report was disabled for some reason. We have it re-activated but the logs for when it was down were not processed. How do we re-process those older logs?

Previously asked at  http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&lang=&cr=&guid=&sloc=en-us&dg=microsoft.public.sharepoint.windowsservices&p=1&tid=f676c989-a369-4761-94e7-ef9b1c28fde7 and referred to here.

Timer usage in a class library

Hi all,     I have a class library, inside a class of this library i want to use a timer, such that for every one second a slot should be called. The code for this is as follows: </>public void OnDataReceive() { System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer(); t1.Enabled = true; t1.Interval = 500; t1.Start(); t1.Tick += new EventHandler(t1_Tick); }   public void t1_Tick(object sender, EventArgs e) { OnReceive(); }   But it is not reaching to this function itself "t1_Tick", Could some one tell me what is wrong in this??? Thanks for any help

Getting AppDomain.UnhandledException event to work in a Windows Service

Nearly every forum thread I have found on "catching unhandled exceptions in a service" seems to end up where I am.  The supposed solution is the use of the AppDomain.CurrentDomain.UnhandledException event.  But it doesn't work for someone, who then asks why and gets no answer.  Same for me; I can't get the event to happen.  It's as if I need the ServiceProcess version of Application.SetUnhandledExceptionMode(), which doesn't exist. For diagnosing this, I start a timer in a child object of the service and then throw an exception in the timer event handler.  Simple enough to simulate the real situation.  I have tried subscribing to the UnhandledException event in at least a half dozen locations throughout the service, from the Program that runs ServiceBase.Run() to the constructor of the object that owns the Timer, but it never catches this exception. The VS debugger recognizes that the forced exception is unhandled and takes me to the place where is thrown, letting me know it is an unhandled exception. Why doesn't my handler catch it?  Running without the debugger, the exception throws, the timer thread crashes, the service continues merrily along, and nothing gets logged anywhere.  That is NOT the result I need.  What are the people for whom this works doing that I am not doing? How can I at least get the offe

Am I able to pass an instance of the Assembly from one AppDomain to another?

I created a wrapper class which inherits from the MarshalByRefObject then loads and returns an assembly in this wrapper class. At the client application side, I used the new created AppDomain and call its CreateInstanceFromAndUnwrap method to create an instance of the wrapper class. Finally I was trying to get the returned assembly from the wrapper object and I got an exception indicating that the assembly file was not found. However if I just return the assembly's name from the wrapper class, it works great, nothing was wrong using that approach. I think maybe this is because that the Assembly class is not inherited from the MarshalByRefObject class so it doesn't make sense to pass between the application domains. I am not sure if my thinking is correct.
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