Archive for category .Net

InfoPath cannot grant access to these files and settings because the form template is not fully trusted. For a form to run with full trust, it must be installed or digitally signed with a certificate – InfoPath 2007 forms Security Levels

After giving the Full Trust to the Form template (See here), we will be able to preview the InfoPath form and get information from other domains, or access files and settings on a user’s computer. But when we publish InfoPath form on SharePoint and try to access the from then you will be getting this error. 😦



Text format of the error:

Form template: file:///C:\Documents%20and%20Settings\RajanihanthV\Desktop\XmlProc\InfoPath\ADInfo.xsn</pre>
The form template is trying to access files and settings on your computer. InfoPath cannot grant access to these files and settings because the form template is not fully trusted. For a form to run with full trust, it must be installed or digitally signed with a certificate.

If we need to access the form from SharePoint, we need to be digitally signed the form even it is fully trusted. This is pretty simple, but we have to do this process after publishing the form on SharePoint only. Here are the steps.

Step 1: Navigate to the Document (form) Library, where your form published

Step 2: Click Settings on the Document Library Settings

Step 3: Advanced Settings

Step 4: Edit Template

Step 5: Click the Form Options on the Tools menu

Step 6: Click Sign this Form Template and create or select certificate, then OK

That’s all. You can try and see. 🙂

This will work only for you (author), If you want give access to all users you have to get the digital signature from 3rd party vendors and signed the form.

Thanks. R./

, , , ,


Request for the permission of type ‘System.DirectoryServices.DirectoryServicesPermission, System.DirectoryServices, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ failed – InfoPath 2007 forms Security Levels

When I was trying to display user information from Active Directory(AD) in an InfoPath form, I have got an error message saying that I don’t have permissions to access the Directory services. 😦

Details of the error message:

Text format of the error:

 Request for the permission of type 'System.DirectoryServices.DirectoryServicesPermission, System.DirectoryServices, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
at Template2.FormCode.GetOU(String username)
at Template2.FormCode.CTRL1_5_Clicked(Object sender, ClickedEventArgs e)
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

I have faced this kind of security level errors while creating a web parts using Active Directory(AD) and you can read this in my previous post.

Basically InfoPath provides three security levels for forms, they are:

  • Restricted
  • Domain
  • Full Trust

The security levels determine whether a form can access data on other domains, or access files and settings on a user’s computer. If you need more info about this, just click here.

When we design/create an InfoPath form, the minimum trust level will be assigned in-default and which is not enough to access the Directory Services. So we need to change the trust level to access the information.  These are the simple steps to change the Trust Levels in InfoPath,

Step 1: Open the Form template in Design Mode

Step 2: Click the Form Options on the Tools menu

Step 3: You will be getting the following window and the security levels automatically determined

Step 4: Unchecked the check box, give the permissions to ‘Full Trust’ and then click OK

That’s all, you can access the Directory Services programmatically and display in your InfoPath form.  Sometimes you will be getting another error after fixing this (probably after publishing to SharePoint), to solve this problem we just need to specify the digitally signed certificate for this form. Check out the error message here.

Thanks. R./

, , , , , , ,


Difference between ‘ref’ and ‘out’ parameters (ref vs out) – C#

  • Both are treated differently @ runtime but same in the compile time, so can’t be overloaded.
  • Both are passed by references except ‘ref’ requires that the variable to be initialized before passed.


class Program
 static void M1(out int i)
 i = 1;
 i += 1;

static void Main(string[] args)
 int j; //Not assigned
 M1(out j);

The output is : 2


class Program
 static void M1(ref int i)
 i = 1;
 i += 1;

 static void Main(string[] args)
 int j=0; //Assigned
 M1(ref j);

The output is same: 2, but we have to assigned the variable before used otherwise we will get an error.

, , , ,


‘Microsoft.SharePoint.Client.Form’ does not contain a constructor that takes 0 arguments – SharePoint 2010 Client Object Model

To fix this issue, just click here. Thanks, R../

, , , ,

1 Comment

‘Form’ is an ambiguous reference between ‘System.Windows.Forms.Form’ and ‘Microsoft.SharePoint.Client.Form’ – SharePoint 2010 Client Object Model

When you try to use the Client Object Model (SharePoint 2010) with Windows Application in Visual Studio 2010, you might be getting these error messages. (You can find the step by step instructions to use the SharePoint 2010 Client Object Model here)

Error Message:

'Form' is an ambiguous reference between 'System.Windows.Forms.Form' and 'Microsoft.SharePoint.Client.Form'

Reason: The reason is obvious and we can get from the error message itself. Yes, after added the  SharePoint Client reference to the code, there is a conflict between ‘System.Windows.Forms.Form’ and ‘Microsoft.SharePoint.Client.Form’! Initially our Form1 class inherits from Form class (by default System.Windows.Forms.Form) and currently our program confuses to choose the correct reference.

Solution: Provide full reference to the Form class will be the solution for this issue, so replace ‘Form‘ with ‘System.Windows.Forms.Form
After Replacing the code:

public partial class Form1 : System.Windows.Forms.Form
 public Form1()

That’s all guys, Happy Programming with Client Object Model.

Thanks, R../


The type or namespace name ‘SharePoint’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?) – SharePoint 2010 Client Object Model dlls

When I started using the Client Object model (Client OM) in SharePoint 2010, I have got this simple error and I just want to share with you in this blog. Following was my develpment environment.

  • Windows 7, 64 bit
  • Console Application Visual Studio 2010
  • Added Client Object Model references (Microsoft.SharePoint.Client.dll & Microsoft.SharePoint.Client.Runtime.dll) to the solution

After setting up all the above, I was trying to add the client reference to the code ‘using Microsoft.SharePoint.Client;‘and then I have got the following error and warnings 🙂

The text format of error is:

"The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)"

It’s an obvious error message and the reason of this error is:

SharePoint 2010 does not support .Net 4.0 in default and Visual Studio 2010 default framework is .Net 4.0.

Here are the simple steps to fix this:

Step 1: Right click on the project –> Properties

Step 2: Change the Target framework –> .Net Framework 3.5

Step 3: Warning message will be popping up, click Yes.

That’s all. Happy Coding..!

Please Note: If you use Windows Application then you will be getting an other error message! 😦 To solve this issue just click here.

, , , , , , , , , ,

1 Comment

Getting started with Silverlight – Visual Studio 2010

Actually this is  my first Silverlight application development, I didn’t get any chance to work with Silverlight in a real time project, so I just wanted to try an application with Silverlight in Visual Studio 2010. It is pretty simple like windows application. 🙂

This is my environment: Visual Studio 2010, Silverlight 4 developer edition and Windows 7.

When I tried to create an application, I have got few version conflict problems and I resolved them. You can see in my previous post if you need. Okay.. we will see the steps.

Step 1: Open the Visual Studio and click New Project

Step 2: Choose the programming language and select Silverlight node in the left pane.

Step 3:  Select the Silverlight application on the middle pane and enter the application name on the Textbox then click ok. 

Step 4: You will be getting the following screen.

Please Note: If you want to enable the WCF RIA Services to access the external data using this application then click the check box. I don’t want to do any, so I just click ok.

Step 5: Here is our solution explorer. If you want to learn about the files and other stuffs just click here and learn more.

Step 6: Just click on the Toolbox on the left side vertical tab (If not shown just click View –> Toolbox OR Ctrl+W, X) and drag and drop the button.

Step 7: Modify the button properties (You can either modify in the property tab on the right side (as usual we do) OR you can modify in the XAML pane).

I have given the button Name=”buttonClick”, Content=”Click”, Height=”50″ and Width=”100″

Step 8: Like button add TextBox and a Label as well. So our design will be displaying like this.

and the XAML:

<Grid x:Name="LayoutRoot" Background="White">
 <Button Content="Click" Height="50" HorizontalAlignment="Left" Margin="152,133,0,0" Name="buttonClick" VerticalAlignment="Top" Width="100" />
 <TextBox Height="25" HorizontalAlignment="Left" Margin="85,70,0,0" Name="textBoxEnter" VerticalAlignment="Top" Width="230" />
 <TextBlock Height="25" HorizontalAlignment="Left" Margin="85,101,0,0" Name="textBlockDisplay" Text="" VerticalAlignment="Top" Width="230" />

Step 9: Double click on the Button to create the click event (You can do this on the right side event tab also) and then write the c# code to getting the string form TextBox and displaying on the Label.

private void buttonClick_Click(object sender, RoutedEventArgs e)
 textBlockDisplay.Text = "Hello " + textBoxEnter.Text;
 buttonClick.Content = "Clicked";

Step 10: That’s all guys, just click the run button (F5) to see our 1st Silverlight application. 🙂

Happy Silverlighing..! We will see the database access later! 🙂

Thanks R./

, , , , , , , ,

1 Comment

System.NullReferenceException in Silverlight application designer in Visual Studio 2010

This is my Environment:

  1. Windows 7 64 bit
  2. VisualStudio 2010 with SilverLight 4 developer runtime

ProblemAfter upgrading the SilverLight 5 client, I tried to create a SilverLight Application and then I have got the following wired error message on the design tab 😦

The text format of the error is:

Object reference not set to an instance of an object.
at Microsoft.Windows.Design.Platform.SilverlightMetadataContext.SilverlightXamlExtensionImplementations.d__8.MoveNext()
at MS.Internal.Design.Metadata.ReflectionProjectNode.BuildSubsumption()
at MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(Identifier identifier)
at MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context)
at MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent, PrefixScope parentScope, IParseContext context, IMarkupSourceProvider provider)
at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(Boolean convertToXamlWithErrors)
at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.get_RootItem()
at Microsoft.Windows.Design.DocumentModel.Trees.ModifiableDocumentTree.get_ModifiableRootItem()
at Microsoft.Windows.Design.DocumentModel.MarkupDocumentManagerBase.get_LoadState()
at MS.Internal.Host.PersistenceSubsystem.Load()
at MS.Internal.Host.Designer.Load()
at MS.Internal.Designer.VSDesigner.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view)
at MS.Internal.Host.Isolation.IsolatedDesigner.Load()
at MS.Internal.Designer.DesignerPane.LoadDesignerView()

Solution: The problem is the conflict of SilverLight versions and I have found the solution in this thread.

Step 1: Uninstall the latest SilverLight client which is SilverLight  5, the 1st one in the below control panel screen shot

Step 2: Uninstall SilverLight 4 developer, the next 1 in the above image

Step 3: Download and Install Microsoft Silverlight 4 Tools for Visual Studio 2010 (Add-on and pre-requisite files for Visual Studio 2010 to develop Silverlight 4 and RIA Services applications)


Installation finished successfully.

Restart the VisualStudio 2010, wow.. it’s working! 🙂

Happy Silverlighting..! Thanks R./




, , , , ,


Constructors and Destructors (C#)

This is for my quick references and I have taken most of the information from MSDN and other web sites. BTW I have written and tested the source!

– Constructors are methods that are executed when an object of a class is created.
– They have the same name as the class.
– A class  may have multiple constructors that take different arguments.
– Constructors enable the programmer to set default values.
– Like class, structs also can have constructors.

There are 3 kind of constructors in .Net (as far as I know), they are

  • Instance Constructors -Used to create and initialize instances of the class
  • Private Constructors – A special type of instance constructor that is not accessible outside the class (cannot be instantiated)
  • Static Constructors – Automatically initialize the class before the first instance is created or any static members are referenced
public class A //Class Name A
public int i;
public A() // Constructor of A
class Program
static void Main(string[] args)
A a = new A(); //Initiated with new Operator
Console.WriteLine("The initialized value is: {0}", a.i);

System.Console.ReadLine(); //This line is to stop the result window

– are used to destruct instances of classes.
– cannot be defined in structs. They are only used with classes.
– A class can only have one destructor.
– cannot be inherited or overloaded.
– cannot be called. They are invoked automatically
– does not take modifiers or have parameters.

class A
public A()


class Program
static void Main(string[] args)
A a = new A(); //Initiated with new Operator

System.Console.ReadLine(); //This line is to stop the result window

Leave a comment