Thursday, March 18, 2010

Error when running tests: Unable to load one or more of the requested types

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..

1. Clean the solution
2. Close Visual studio
3. Delete all the bin en obj folders
4. Try again

Monday, March 15, 2010

Sharepoint configuration wizard fails after sysprep

If you sysprep a machine on which you installed sharepoint and ran the configuration wizard and you try to run it again you get the following error (after you ran the sp_dopserver and sp_addserver stored procedures):

03/05/2010 17:16:12 8 ERR Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: password
at Microsoft.SharePoint.Administration.SPProcessIdentity.Update()
at Microsoft.SharePoint.Administration.SPApplicationPool.Update()
at Microsoft.SharePoint.Administration.SPWebApplication.CreateDefaultInstance(SPWebService service, Guid id, String applicationPoolId, IdentityType identityType, String applicationPoolUsername, SecureString applicationPoolPassword, String iisServerComment, Boolean secureSocketsLayer, String iisHostHeader, Int32 iisPort, Boolean iisAllowAnonymous, DirectoryInfo iisRootDirectory, Uri defaultZoneUri, Boolean iisEnsureNTLM, Boolean createDatabase, String databaseServer, String databaseName, String databaseUsername, String databasePassword, SPSearchServiceInstance searchServiceInstance, Boolean isPaired, Boolean autoActivateFeatures)
at Microsoft.SharePoint.Administration.SPAdministrationWebApplication.CreateDefaultInstance(SqlConnectionStringBuilder administrationContentDatabase, SPWebService adminService, IdentityType identityType, String farmUser, SecureString farmPassword)
at Microsoft.SharePoint.Administration.SPFarm.CreateAdministrationWebService(SqlConnectionStringBuilder administrationContentDatabase, IdentityType identityType, String farmUser, SecureString farmPassword)
at Microsoft.SharePoint.Administration.SPFarm.CreateBasicServices(SqlConnectionStringBuilder administrationContentDatabase, IdentityType identityType, String farmUser, SecureString farmPassword)
at Microsoft.SharePoint.Administration.SPFarm.Create(SqlConnectionStringBuilder configurationDatabase, SqlConnectionStringBuilder administrationContentDatabase, IdentityType identityType, String farmUser, SecureString farmPassword)
at Microsoft.SharePoint.Administration.SPFarm.Create(SqlConnectionStringBuilder configurationDatabase, SqlConnectionStringBuilder administrationContentDatabase, String farmUser, SecureString farmPassword)
at Microsoft.SharePoint.PostSetupConfiguration.ConfigurationDatabaseTask.CreateOrConnectConfigDb()
at Microsoft.SharePoint.PostSetupConfiguration.ConfigurationDatabaseTask.Run()
at Microsoft.SharePoint.PostSetupConfiguration.TaskThread.ExecuteTask()


This is related to the fact that there are allready Application pools created. if you delete the earlier created applicaiton pools and websites you should be able to run the wizard without errors.

Thursday, March 11, 2010

Ax Business Connector .NET Unable to log on to Microsoft Dynamics AX.

LogonFailedException: Unable to log on to Microsoft Dynamics AX.

Method signature
public void LogonAs(
string user,
string domain,
NetworkCredential bcProxyCredentials,
string company,
string language,
string objectServer,
string configuration
);

When using the logon as method of the Business Connector .NET you face a lot off issues. After searching on the net I found that almost everyone forces the bcProxyCredentials but actually this not the way it is supposed to be used.

but here the MSDN documentation contains an error:

bcProxyCredentials
Credentials of the Business Connector Proxy user used to authenticate and enable the use of LogonAs.

You can create a NetworkCredential object with the following code:

System.Net.NetworkCredential creds = new System.Net.NetworkCredential(
ADUserName, ADUserPassword, ADDomain)The NetworkCredential parameters must match the Business Connector Proxy user set in the Business Connector Proxy dialog box: To verify your settings go to the Administration pane, click Setup, click Security, and then select BusinessConnectorProxy.

the part in bold is wrong. If you open the client application got the Administration pane > Security > System Service Accounts and there you can set the Business Connector Proxy accound and you can perform the LogonAs method to imperonate another user.

From the installation guide:

Some components require that the .NET Business Connector be configured to connect to Microsoft Dynamics AX with a proxy account. The use of a proxy enables the .NET Business Connector to connect on behalf of Microsoft Dynamics AX users when authenticating with an AOS instance.

Next you should be able to use the LogonAs method to logon as any valid Axapta user

Edit: if you want to use the user that is running the process as the proxy account pass null to the LogonAs method for the bcProxyCredentials parameter

Friday, March 05, 2010

Booting from a VHD

With windows 7 and windows 2008 it is possible to boot from a hyper-v virtual disk

I usually set up an image with hyper-v and sysprep it then follow these steps to add it to your bootloader

C:\Windows\system32>bcdedit /copy {current} /d "JELLE-DEV"
The entry was successfully copied to {8208ac27-0bca-11df-8dbb-a0ef01535d7b}.

Copy the GUID that is

bcdedit /set {guid} device vhd=[locate]\image.vhd
bcdedit /set {guid} osdevice vhd=[locate]\image.vhd

Wednesday, March 03, 2010

Webcam access in Silverlight 4

Code snippet to show webcam capture in silverlight 4


CaptureDeviceConfiguration.RequestDeviceAccess();
CaptureSource _capture = new CaptureSource();
_capture.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
_capture.Start();
VideoBrush videoBrush = new VideoBrush();
videoBrush.Stretch = Stretch.Uniform;
videoBrush.SetSource(_capture);
rectVideo.Fill = videoBrush;
rectVideo.UpdateLayout();


Getting the output and resizing it to have a format of a picture that can be used in a profile


_capture.AsyncCaptureImage(img =>
{
_capture.Stop();
TranslateTransform tt = new TranslateTransform();

tt.Y = -73.5;
tt.X = -125;
WriteableBitmap bitmap = new WriteableBitmap(70, 93);

bitmap.Render(rectVideo, tt);
bitmap.Invalidate();
frameImage.Source = bitmap;
_capture.Start();
});