Showing posts with label WCF. Show all posts
Showing posts with label WCF. Show all posts

Monday, 29 December 2014

The Process cannot access the file because it is being used by another process.(Exception from HRESULT: 0x80070020)

The Process cannot access the file because it is being used by another process.(Exception from HRESULT: 0x80070020)












This kind of Issue will come with Binding Conflict.There is an another application that is using port number 80.


You can run NETSAT -ano and find out the PID, May be the Process name Skype.exe






Could not load file or assembly 'Newtonsoft.json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

Could not load file or assembly 'Newtonsoft.json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

This kind of Errors will come if Pointing to the Wrong version of dll's.


In Package manager Console Execute: Update-Package -reinstall Newtonsoft.Json.

If you facing an Error after executing the Command, Change the Version of Json in web.config or app.config.




  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


I Think you you are pointing to Wrong version, change it 4.5.0.0 to 6.0.0.0


Monday, 8 December 2014

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. Entity FrameWork

I got an Error in Entity framework while insertion of Records.

Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.























This kind of Issue's will come in various causes, We can  watch the Entity frame work Errors in visual studio with the Following Code.

   

    catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                Exception ErrorRaise = ex;
                foreach (var validationErrors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string errorMessage = string.Format("{0}:{1}",
                            validationErrors.Entry.Entity.ToString(),
                            validationError.ErrorMessage);

                        ErrorRaise = new InvalidOperationException(errorMessage, ErrorRaise);
                    }
                }
                throw ErrorRaise;
            }



Tuesday, 18 November 2014

Container creation in Azure Storage

Every blob in the AzureStorage must reside in the Container.
Today i would like the simple way of creation of Containers from c#.Net, We can also create containers from Azure Management portal.

We need to configure Storage account connection String that i explained my earlier post

Configuring Azure Connection string using .Net Application

Next we need to add namespace declaration in the top of c# programming file, for accessing Azure Storage.

make sure we need to add reference the Microsoft.windowsAzure.Storage.dll

using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
  


// Retrieve storage account from connection string.           
 CloudStorageAccount storageAccount = CloudStorageAccount.Parse( 
ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
              
 // Create the blob client.
  CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
                

// Retrieve a reference to a container.
  CloudBlobContainer container = blobClient.GetContainerReference("MyPictures");

 // Create the container if it doesn't already exist.
 container.CreateIfNotExists();


By default containers are private in, we can also give the permissions for downloading the blobs.