.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

can I tell programmatically whether the code is running in sandbox?

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :SharePoint

The title says it all really! I want to be able to check in my code whether the current environment is live or sandbox - is it possible?



View Complete Post

More Related Resource Links

Is your code running in a SharePoint Sandbox?


You could execute a function call that is not allowed in the sandbox (for example call a static method on SPSecurity) and catch the exception. A better approach is to test the friendly name of you app domain:

AppDomain.CurrentDomain.FriendlyName returns "Sandboxed Code Execution Partially Trusted Asp.net AppDomain"

Because you can never be sure that this string changes in the future, a safer approach will be:


See http://www.sharepointoverflow.com/questions/2051/how-to-check-if-code-is-running-as-sandboxed-solution for a discussion on this topic.

Wicked Code: Running ASMX Web Services on STA Threads


Jeff Prosise describes performance problems in an ASMX Web service that relied on legacy COM and Visual Basic 6.0 to perform key processing tasks and the approach he took to find a fix.

Jeff Prosise

MSDN Magazine October 2006

High Availability: Keep Your Code Running with the Reliability Features of the .NET Framework


Reliability requires the capacity to execute a sequence of operations in a deterministic way, even under exceptional conditions. This allows you to ensure that resources are not leaked and that you can maintain state consistency without relying on application domain unloading (or worse, process restarts) to fix any corrupted state. Unfortunately, in the.NET Framework, not all exceptions are deterministic and synchronous, which makes it difficult to write code that is always deterministic in its ability to execute a predetermined sequence of operations. In this article Stephen Toub will show you why, and explore features of the .NET Framework 2.0 that help you to mitigate these situations and write more reliable code.

Stephen Toub

MSDN Magazine October 2005

.NET Internals: Examine Running Processes Using Both Managed and Unmanaged Code


There are plenty of times when you need to get information on running processes, not the least of which is during performance tuning. Using the techniques in this article and special .NET classes you'll see how to get a process' ID, name, priority, number of threads, kernel handle, and memory consumption, as well as its user-mode, kernel-mode, and total elapsed running time and put them to use in a custom app called AssemblyBrowser.

Christophe Nasarre

MSDN Magazine October 2004

Code Name Indigo: A Guide to Developing and Running Connected Systems with Indigo


This article describes a collection of new programming frameworks that are part of "Longhorn," the upcoming version of Windows. "Indigo," the code name for this framework, provides rich support for service-oriented design that is complementary to traditional object-oriented approaches. Indigo marries the best features of .NET Remoting, ASMX, and .NET Enterprise Services into a unified programming and administration model. Indigo's deep support for standard protocols, including HTTP, XML, and SOAP, makes it easier to integrate applications and services without sacrificing security or reliability.

Don Box

MSDN Magazine January 2004

Video: SharePoint 2010: Executing Code in the Sandbox

Find out how the Sandboxed Solutions Service provides for a complete isolation system that ensures code running in a sandboxed solution cannot reach out to access information beyond the scope of the deployment. (Length: 12:01)

Detect if code is running inside SQL Server.

Can managed code "detect" if it is running in the normal .Net CLR or the special SQL Server CLR? Is there some environment flag or field we can look at at runtime? Thanks Cap'n  

Issues with running SSIS packages programmatically

Hi, I have spent days trying to solve this problem and still stuck with this and I have posted some questions already in forums, but didn't get satisfactory answers. I am trying to be more clear this time and hope to get a better answer. I have gone through this article already http://blogs.msdn.com/b/michen/archive/2007/03/22/running-ssis-package-programmatically.aspx and here are my issues (I need to run the SSIS package from ASP.NET) option 1 is not suitable for me, because it may recycle worker process if it consumes memory option 2 is also not suitable because of security issues in creating a new process and passing the context to new process looks very complicated for me (according to the support article) option 3 is not suitable because using SQL Server Agent to run SSIS package is not allowed by the company I am working for(I guesss it requires installation of db engine on application server, not sure). but SSIS is installed on the application server. option 4&5 will have the same issues as options 1&2. I guess the only option left now is to create a windows service and start the service from ASP.NET. but will this allow running multiple packages in parallel? OR is there a better alternate solution for this? please let me know. Thanks.

I am using the following code to check to see if a panel is visible or not before running javascript

Using VB, VS 2010, when I run the following code, I get an error because it executes the code even if I have Panel7 set to invisible.  I am trying to use javascript to see if the panel is visible or not before executing the code.var panelRef7 = document.getElementById('<%= Panel7.ClientID %>'); if (panelRef7) { $find('DragP7').add move(savePanelPosition); }  What am I doing wrong?   Thanks

Running code after site definition site creation in a event receiver or feature receiver

Hi guys I've got a site definition which is pretty much based on STS.This is it's own sharepoint project. Let's call this project SiteDefProj. Next in another SharePoint project (same solution though). Let's call this CustomListProject. In this project I've got a feature which provisions a bunch of lists based on custom content types - this feature is a site scoped. Let's call this feature: CustomListInstances. I have added a feature receiver to this feature to execute some custom code on the lists themselves (under feature activated) In my ONET.XML (part of the SiteDefProj) I have CustomListInstances feature ID as part of my <sitefeatures>. When I do a create site I can actually step through the code and see it actually being executed but after the site is created the list instances are created but it's like the code never run or did anything. The weird part is that stepping through the code while creating a site collection using my SiteDefProj the code runs great with no errors. All lists are there and the code runs smooth. If I manually create a STS site and activate my feature everything works and the code does actually run and the effects are visible after the feature is created. Again I can actually step through it in debug. My suspicion is that there's some sort of a race condition in the CREATE SITE functionality where maybe the web or site collection hol

Release mode application throws Break instruction exception - code 80000003 when running in WinDbg


Here is the initial output of my program after running it from WinDbg:

CommandLine: "C:\Documents and Settings\Administrator\My Documents\Work\QMI_Test_Tool\QMI_UT_Source\Release\QMI Validation Tool.exe"
Symbol search path is: SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
Executable search path is: 
ModLoad: 00400000 0048f000  QMI Validation Tool.exe
ModLoad: 7c900000 7c9b2000  ntdll.dll
ModLoad: 79000000 7904a000  C:\WINDOWS\system32\mscoree.dll
ModLoad: 7c800000 7c8f6000  C:\WINDOWS\system32\KERNEL32.dll
ModLoad: 77dd0000 77e6b000  C:\WINDOWS\system32\advapi32.dll
ModLoad: 77e70000 77f03000  C:\WINDOWS\system32\RPCRT4.dll
ModLoad: 77fe0000 77ff1000  C:\WINDOWS\system32\Secur32.dll
ModLoad: 7c420000 7c4a7000  C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989\MSVCP80.dll
ModLoad: 78130000 781cb000  C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989\MSVCR80.dll
ModLoad: 77c10000 77c68000  C:\WINDOWS\system32\msvcrt.dll
ModLoad: 7c9c0000 7d1d7000  C:\WINDOWS\system32\SHELL32.dll
ModLoad: 77f10000 77f59000  C:\WINDOWS\system32\GDI32.dll
ModLoad: 7e410000 7e4a1000  C:\WINDOWS\system32\USER32.dll
ModLoad: 77f60000 77fd6000  C:\WINDOWS\system32\SHLWAPI.dll
ModLoad: 7c4c0000 7c53d000  C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989\m

Can a stored procedure programmatically determine if an SSIS package is running?



If I have the 'ExecutionInstanceGUID' value for an SSIS package that I know was started, is there a way that a stored procedure can programmatically determine whether the SSIS package still is running?

Thanks -



Running a feature activated code during new site provisioning.

I would like to be able to run some simple code that have in a feature whenever a new site is provisioned.  I created the feature and it works just like I want it to.  I left it activated and saved the site template.  Now when I create a new site based on the saved site template the feature activated code no longer runs unless I deactivate and then activate.  I know this isn't suppose to work this way, and after much searching on the internet I am finding the feature stapling (not what I want, that seems to be what I have already done) and SPWebProvisionProvider.  The provider might be what I want but I am not sure how it works and there are no good examples on how to get one created in code and where to place it so that a user can utilize it when creating a new site.  Can someone explain this concept to me in ad nauseum detail.  Thanks in advance.

Can't access static member in code, but while running "QuickWatch" sees it. What the?


HI everyone,

I'm working with two Visual Studio 2005 solutions.

The first is "WinX" with a project called "WinX". There's a class in the WinX project in a namespace called "WinX" with a class "frmMain". frmMain is the main form for the application, and is always open.

We have this static member declared as so in frmMain:

public static bool IsfrmViewTaskFormOpen = false;

Enter our second solution "TasksProcessScreen" with a project "TasksProcessScreen" which has a namespace of "TasksProcessScreen" with a public class frmViewTask. The solution has the "WinX" project added as a project.

In frmViewTask, there is the following code:

private void frmViewTask_FormClosed(object sender, FormClosedEventArgs e)


   //This does NOT compile! It says "WinX" does not exists in the current context.

   if (WinX.frmMain.IsfrmViewTaskFormOpen)

programmatically set hyperlink state in code behind of a web user control


I am writing a web user control that is basically a vertical single level menu.  The layout would look like this:

<asp:Table ID="myTable" runat="server">
            <asp:HyperLink>Menu Choice</asp:HyperLink>  /* which would resolve to the following line.
            <a onclick="__doPostBack('theUniqueIdOfTheUserControl','myArguments');">Menu choice</a>
    . . . etc.

However, I am externalizing the layout to an XML file and am building the table content dynamically.  The source view of the ascx actually looks like this:

<asp:Table ID="myTable" runat="server">

In the Page_Load of the code behind, I read and parse the XML file and save all the pertinent data in the viewstate on the first load.  On all loads including postbacks, I create the rows, cells, and hyperlinks from the viewstate so I don't have to parse the XML file on every postback.

The XML file also specifies CssClasse

Edit code when your ASP.NET Development Server is running

The article Edit code when your ASP.NET Development Server is running was added by pradip.bobhate on Saturday, January 29, 2011.

Lot of people trying to edit the code when ASP.NET Development Server is running but they can't. In order to edit code you have to stop debugger/ ASP.NET Development server then you can edit it.If you want to continue code edit while your are running

while running the code buttons are not appearing on form


i wrote a copy web service i added two web reference first for list and second for copy i took two buttons on first click i wrote a code for getting address of attachments  and on second click i wrote copy functionality for copying some attachments into another list in 2 different site now my code is error free  but while running i am not getting buttons on form my code is- 




public partial class Form1 :
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