Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all 1710 articles
Browse latest View live

System.TypeInitializationException was unhandled by user code ERROR please help

$
0
0

I am busy with an e-commerce web application using visual studio 2005 and IIS 7

I got this error

System.TypeInitializationException was unhandled by user code

  Message="The type initializer for 'ShopConfiguration' threw an exception."

  Source="App_Code.r-ihwy-d"

  TypeName="ShopConfiguration"

  StackTrace:

       at ShopConfiguration.get_DbProviderName()

       at GenericDataAccess.CreateCommand() in c:\inetpub\wwwroot\Beadafrican\App_Code\GenericDataAccess.cs:line 63

       at CatalogAccess.GetDepartments() in c:\inetpub\wwwroot\Beadafrican\App_Code\CatalogAccess.cs:line 28

       at UserControls_DepartmentsList.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Beadafrican\UserControls\DepartmentsList.ascx.cs:line 22

       at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

       at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)

       at System.Web.UI.Control.OnLoad(EventArgs e)

       at System.Web.UI.Control.LoadRecursive()

       at System.Web.UI.Control.LoadRecursive()

       at System.Web.UI.Control.LoadRecursive()

       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

 

If I look at the code it refers to I dont see what is wrong? Here is the code if anyone can please assist it would be great!

GenericDataAccess.cs:

public static class GenericDataAccess
{
    //static constructor
    static GenericDataAccess()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    //execute a command and returns the result as a DataTable Object
    public static DataTable ExecuteSelectCommand(DbCommand command)
    {
        //The DataTable to be returned
        DataTable table;
       
        //Execute the command making sure the connection gets closed in the end
        try
        {
            //open the data connection
            command.Connection.Open();
           
            //Execute the command and save the results in a DataTable
            DbDataReader reader = command.ExecuteReader();
            table = new DataTable();
            table.Load(reader);
            
            //Close the reader
            reader.Close();
        }
        catch (Exception ex)
        {
            Utilities.LogError(ex);
            throw ex;
        }
        finally
        {
            //Close the connection
            command.Connection.Close();
        }
        return table;
    }

    //creates and prepares a new DbCommand object on a new connection
    public static DbCommand CreateCommand()
    {
        //Obtain the database provider name
        string dataProviderName = ShopConfiguration.DbProviderName;
        
        //Obtain the database connection string
        string connectionString = ShopConfiguration.DbConnectionString;
        
        //Create a new data provider factory
        DbProviderFactory factory = DbProviderFactories.GetFactory(dataProviderName);
        
        //Obtain a database specific connection object
        DbConnection conn = factory.CreateConnection();
        
        //Set the connection string
        conn.ConnectionString = connectionString;
        
        //Create a database specific command object
        DbCommand comm = conn.CreateCommand();
        
        //Set the command type to stored procedure
        comm.CommandType = CommandType.StoredProcedure;
        
        //Return the initialised command object
        return comm;
    }

 

 

CatalogAccess.cs

public static class CatalogAccess
{
    static CatalogAccess()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    //Retrieve the list of departments
    public static DataTable GetDepartments()
    {
        //get configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        //set the stored procedure name
        comm.CommandText = "GetDepartments";

        //execute the stored procedure and return the results
        return GenericDataAccess.ExecuteSelectCommand(comm);


    }
}

 

DepartementList.ascx.cs

public partial class UserControls_DepartmentsList : System.Web.UI.UserControl
{
    // Load department details into the DataList
    protected void Page_Load(object sender, EventArgs e)
    {
        // don't reload data during postbacks
     
       {
            // CatalogAccess.GetDepartments returns a DataTable object containing
            // department data, which is read in the ItemTemplate of the DataList
            list.DataSource = CatalogAccess.GetDepartments();
            // Needed to bind the data bound controls to the data source
            list.DataBind();
            
        }
    }
}

 


Enhanced Strong Naming

$
0
0
I am testing Enhanced Strong Naming (http://msdn.microsoft.com/en-us/library/hh415055.aspx) and having some problems getting it into a build process. According to the article you have to delay-sign assemblies first and then re-sign them to get proper Enhanced String Name. That does not work well with the build process. Usually we delay-sign assemblies while developing, and fully sign them on build servers. Does anyone have any experience with Enhanced String Naming?

Access violation at gc_heap::mark_object_simple

$
0
0

I am having access violation exception in our Windows Service

In WER416F.tmp.hdmp the assembly instruction at clr!WKS::gc_heap::mark_object_simple+6d inC:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll from Microsoft Corporation has caused an access violation exception (0xC0000005) when trying toread from memory location 0x00000000 on thread 42

Here is call stack:

Function
clr!WKS::gc_heap::mark_object_simple+6d
clr!WKS::GCHeap::Promote+62
clr!GcStackCrawlCallBack+b9
clr!Thread::StackWalkFramesEx+fd
clr!Thread::StackWalkFrames+be
clr!CNameSpace::GcScanRoots+148
clr!WKS::gc_heap::mark_phase+177
clr!WKS::gc_heap::gc1+96
clr!WKS::gc_heap::garbage_collect+222
clr!WKS::GCHeap::GarbageCollectGeneration+dd
clr!WKS::GCHeap::Alloc+31b
clr!AllocateArrayEx+3ef
clr!JIT_NewArr1+241
mscorlib_ni+4fd20d
mscorlib_ni+4e84ce
SMDiagnostics_ni+1c0b9
System_Xml_ni+155312
System_ServiceModel_ni+e889d5
System_ServiceModel_ni+10ea678
SMDiagnostics_ni+1b095
SMDiagnostics_ni+1b22d
System_ServiceModel_ni+e07138
System_ServiceModel_ni+635444
System_ServiceModel_ni+f5ee13
System_ServiceModel_ni+f5c689
System_ServiceModel_ni+12a239f
System_ServiceModel_ni+123598a
System_ServiceModel_ni+618d4b
System_ServiceModel_ni+618bf3
System_ServiceModel_ni+6189ad
System_ServiceModel_ni+617a2a
System_ServiceModel_ni+6124c6
System_ServiceModel_ni+611b2b
System_ServiceModel_ni+61053e
System_ServiceModel_ni+60fa57
System_ServiceModel_ni+60de03
System_ServiceModel_ni+60d92b
System_ServiceModel_Internals_ni+be465
System_ServiceModel_Internals_ni+be0a4
System_ServiceModel_Internals_ni+4e651
System_ServiceModel_Internals_ni+4e5d0
mscorlib_ni+535c26
clr!CallDescrWorkerInternal+83
clr!CallDescrWorkerWithHandler+4a
clr!DispatchCallSimple+85
clr!BindIoCompletionCallBack_Worker+b8
clr!Frame::Push+a0
clr!Frame::Pop+86
clr!ManagedPerAppDomainTPCount::DispatchWorkItem+2bd
clr!ManagedPerAppDomainTPCount::DispatchWorkItem+23b
clr!BindIoCompletionCallbackStubEx+cd
clr!BindIoCompletionCallbackStub+9
clr!ThreadpoolMgr::CompletionPortThreadStart+361
clr!Thread::intermediateThreadProc+7d
kernel32!BaseThreadInitThunk+d
ntdll!RtlUserThreadStart+1d

Any idea what's wrong or where to start investigating it?


passing a float value by reference to unmanaged code to be used in callbacks: I'm missing something ...

$
0
0

Conside the 'thought-experiment' straight C routine:

void setToThree(float *v)
{
  if (v == NULL) return;
  *v = 3.0;
}

This won't care (in C) if you pass a pointer to a float variable or to an array of 1 float:

float v_value;
float v_array[1];

setToThree(&v_value) -> v_value = 3.0;
setToThree(v_array) -> v_array[0] = 3.0; // or maybe 3.000000000000004

Let's put this in a DLL along with the ability to fire a callback at some interval.  The idea being, I want to be able to update from this callback some VB.NET Single variable whenever the callback is fired (still a thought experiment here).

So assume some C# .NET dll that does the interop and that might have a class 'Three': 

public class Three
{  private object threeObject = null;
    private float threeFloat;
    private IntPtr threePtr;
    private GCHandle gch;

    public delegate void TimedCallback();

    private TimedCallback vbCallback; 

    public void SetToThree(ref float v)
    {
      threeObject = v;
      threeFloat = v;
      unsafe { fixed (float* p = &v) threePtr = new IntPtr((void*)p); }
      gch = GCHandle.Alloc(v, GCHandleType.Pinned);
      native.setToThree(ref threeFloat);
    }

    public unsafe void nativeTimedCallback() // to be passed to the C DLL
    {
      if (threeObject != null)
      {
        native.setToThree(ref threeFloat);
      //  *(float*)gch.AddrOfPinnedObject().ToPointer() = threeFloat;
        *(float *)threePtr = threeFloat;
      }

     if (vbCallback != null) vbCallback();
  }
  public StartThreeCallback(ref float v,TimedCallback cb) 
  {

     SetToThree(v);

     vbCallback = cb;
  }
}

Of course without the callback business, just calling SetToThree() without all the pinning, etc. would do the trick.  But continuing with my dilemma, suppose in VB you call the StartThreeCallback() and try to do something like:

  Dim fv As Single
  Delegate Sub vbcbDelegate()
  Public Sub vbcb()
    If sumcurrent.InvokeRequired = True Then
      Invoke(New vbcbDelegate(AddressOf vbcb))
      Exit Sub
    End If
    label1.Text = "value: " + Str(fv)
    fv = 4.0
  End Sub

I want to see label1 always show me '3' and never '4'. Assuming there's a timer calling the callback every second, this actually works for a few rounds and then just stays put at '4'.   Something seems to have moved (in spite of the 'pinned'), but at least nothing ever crashes.  If I use the (commented out in nativeTimedCallback) 'AddrOfPinnedObject' variant, it never works (always see a '4')!  In the debugger I see that the "fixed (float* p = &v) threePtr = new IntPtr((void*)p);" way of getting a pointer gives a different IntPtr than AddrOfPinnedObject().  Hmmm....

If I make the overloads to handle a float[] value and use a Dim v(0) As Single in VB it always works (and 'AddrOfPinnedObject' is the way to go here)! 

What am I missing concerning updating a single variable passed by reference from an unmanaged callback?

 Thanks in advance!

How to report a bug to microsoft?

$
0
0
Hi all,

Now I'm pretty sure that the problem I explained in the post
"More info about the problem with XML signature from a SC" (
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=225235&SiteID=1)
its a bug on the 2.0 framework. Does anybody know how to report a bug to microsoft?

Thanks.

The failure of unmanaged code(Delphi) consumes Com from .Net

$
0
0

We have  to access  a Com dll that is developed by C#,    when its codebase register(regasm) as local path, works fine. but when its codebase is mapped driver, it throws the error "interface not supported" by Delphi7. From FUSLOGVW.exe, find the Com DLL has bound successfully.  also I tested to use Caspol.exe to grant full trust to mapped driver, like:

Caspol.exe -m -ag 1.2 -url file://S:\ComClass.DLL FullTrust.

I'm wondering if the managed com dll can not be registered as mapped driver????

*** Assembly Binder Log Entry (2013-11-8 @ 15:28:14) *** The operation was successful. Bind result: hr = 0x0. The operation completed successfully. Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll Running under executable D:\project\TestCom.exe --- A detailed error log follows. === Pre-bind state information === LOG: User = JASON-DELPHI7WI\Dev LOG: Where-ref bind. Location = S:/ComClass.DLL LOG: Appbase = file:///D:/project/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = TestCom.exe Calling assembly : (Unknown). === LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). LOG: No application configuration file found. LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Attempting download of new URL file:///S:/ComClass.DLL. LOG: Assembly download was successful. Attempting setup of file: S:\ComClass.dll LOG: Entering run-from-source setup phase. LOG: Assembly Name is: ComClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ec829f3f15982550 LOG: Re-apply policy for where-ref bind. LOG: Post-policy reference: ComClass, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ec829f3f15982550 LOG: GAC Lookup was unsuccessful. LOG: Where-ref bind Codebase does not match what is found in default context. Keep the result in LoadFrom context. LOG: Binding succeeds. Returns assembly from S:\ComClass.dll. LOG: Assembly is loaded in LoadFrom load context.




Why "RuntimeHelpers.Equals" slower then "Object.Equals" ?

$
0
0

Hi,

Anyone can explain me why "System.Runtime.CompilerServices.RuntimeHelpers.Equals " slower then "Object.Equals" ?
I test with 100,000,000 chars by compare it self like Tmp = Text(i) : IsEqual =  Object.Equals(Tmp, Text(i)).
Result of test I get is "Object.Equals"  2.7 sec and "RuntimeHelpers.Equals" 3.3 sec, but when I look at IL code of Object.Equals it use "RuntimeHelpers.Equals" inside that make me confuse how could "RuntimeHelpers.Equals" slower then "Object.Equals" ?

  IL_0000:  ldarg.0
  IL_0001:  ldarg.1
  IL_0002:  call       bool System.Runtime.CompilerServices.RuntimeHelpers::Equals(object,object)
  IL_0007:  ret

Instantiate Shell32.Shell object in Windows 8

$
0
0

Hi,

I want to instantiate the Shell32.Shell object in Windows 8. I have created a small console project in VS 2012, added reference to Microsoft Shell Controls and Automation. When running the following code

namespace Shell32Test
{
  class Program
  {
    static void Main(string[] args)
    {
      object shell = new Shell32.Shell();
    }
  }
}

The invalid cast exception occurs.

Details of the exception:

System.InvalidCastException was unhandled
  HResult=-2147467262
  Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{286E6F1B-7113-4355-9562-96B7E9D64C54}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
  Source=Shell32Test
  StackTrace:
       at Shell32Test.Program.Main(String[] args) in c:\Users\christ.ADLIB\Documents\Visual Studio 11\Projects\Shell32Test\Shell32Test\Program.cs:line 8
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Any ideas how to solve this issue?

Thanks,

C.


What is error ioibmurhynrxkw0zxkyrvfn0boyyufow clr20r3

$
0
0

Program crashes on startup with this strange error:

EventType clr20r3, P1 <app_name>.exe, P2 2.2.0.0, P3 527a0217, P4 system.configuration, P5 2.0.0.0, P6 4889de74, P7 9d, P8 48, P9 ioibmurhynrxkw0zxkyrvfn0boyyufow,

I have installed and can able to open the same application in other system(Windows Embedded, 7 and XP).

The .net framework 3.5 sp1 is installed in my machine.
pls help to sort the issue


problem used!!!!!!

$
0
0

Error    1    The type or namespace name 'CloudToolkitN6' could not be found (are you missing a using directive or an assembly reference?)

this error appear when I do debug for my project!!! I cant use this components

please help my to how add this component correct to toolbox!!thanx

How to force all calls from unmanaged host app into managed plugin to MTA

$
0
0

Hi

I am writing a managed plugin for an 3rd party unmanaged non-COM host application. But because all the interfaces that are used to communicate between host and plugin are COM compatible, I use COM-interop to help me with the interop between unmanaged and managed. The entry point of the plugin is an exported function that is called by the host (DllExportAttribute). But the host app is not COM, it does not call CoInitialize or CoCreateInstance or any of that. So it's not a plain vanilla COM-interop scenario!

I am making good progress in implementing this plugin - however I ran into a problem that I think may have to do with the type of apartment the CLR has assigned to the calling unmanaged threads (I know for sure that there are more than one threads used in the unmanaged host to call into the plugin). I want all calls from the unmanaged host to run in the MTA (free threading) so I don't have the overhead of sync/pumping of the STA. 

My question is: how can I make the CLR assign MTA to incoming threads, instead of STA?

Thanx, Marc


Marc Jacobi

.net com interop security

$
0
0

Hello

As a very newb to security issues, I'm looking for some clue about security model/issues/privileges/solutions/attributes/... of .net com interop. Something like starting point article, code samples and ... 

I have third party com servers that I'm not sure other than their stated functionality, what else they may do. I want to restrict its access to whatever unnecessary like creating files, starting new com sessions, ....

A special important question: is is possible to start a com server as another user with restricted rights?

Could anybody please help?

Contradicting articles about .NET 4 backwards compatibility

$
0
0

Hi,

I found that two MSDN articles about the backward compatibility of .NET 4 seem to contradict each other:

 

"When you install version 3.5, you get the 2.0 and 3.0 layers automatically, and apps that were built for versions 2.0, 3.0, and 3.5 can all run on version 3.5. However, the .NET Framework 4 ends this layering approach, so apps built for 2.0. 3.0, or 3.5 will not work on version 4 or later."

http://msdn.microsoft.com/en-us/library/bb822049.aspx

VS.

"The .NET Framework 4.5 is backward-compatible with applications that were built with the .NET Framework versions 1.1, 2.0, 3.0, 3.5, and 4.In other words, applications and components built with previous versions of the .NET Framework will work on the .NET Framework 4.5."

http://msdn.microsoft.com/de-de/library/ff602939%28v=vs.110%29.aspx

As different other articles also state that .NET 4 is compatible with earlier versions of .NET (e.g. this onehttp://msdn.microsoft.com/en-us/library/jj152935%28v=vs.110%29.aspx), I am pretty sure that this is correct. Nevertheless, out of pure interest: did I miss something in the first article, or is it just wrong?

Regards,

Felix

winmm.dll exception

$
0
0

ok im new to C# programming and i hit a snag that im confused about. im trying to make a mediaplayer and i got the basics to work but when i tried to add things like Volume control i looked up that i needed to inport the winmm.dll file, but when i run the app i get the        $exception    {"Unable to load DLL 'C:/Windows/System32/winmm.dll)': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}    System.Exception {System.DllNotFoundException}

this is the code, be nice im new:)

 
        [DllImport("C:/Windows/System32/winmm.dll)")]
        public static extern int waveoutgetVolume(IntPtr owh, out uint VolumeVX);
        
        [DllImport("C:/Windows/System32/winmm.dll")]
        public static extern int waveoutsetVolume(IntPtr owh, out uint VolumeVX);

if thats not enough i will put more of my code


How to debug an executable

$
0
0

Hi,

I run into a dead end with a Windows application written in C#. If I open my source code in Visual Studio 2010 and hit "F5",everything runs fine.

I then build it into a msi installer, then install this application. However, when I run this installed application, it constantly dies with this error message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." How do I debug this executable?

Please help - customer is pushing for release and I am stuck here. Many thanks!


How to set different references in debug and release mode

$
0
0
Hi
I have a C# application end a C# assembly. I can compile both in release and debug version. In the C# application I'd like to refer the release assembly version in release mode and the debug version for the debug.
Is it possible? In VS 2005 you have just one list of references for both release and debug.
Marco

GDI+ error when saving an image

$
0
0

In http://social.msdn.microsoft.com/Forums/vstudio/en-US/b15357f1-ad9d-4c80-9ec1-92c786cca4e6/bitmapsave-a-generic-error-occurred-in-gdi?forum=netfxbcl, someone suggests a workaround through a memory stream to solve 'generic GDI+ error' exceptions when saving an image to a file.

However, I have this problem when saving to a memory stream in the first place.

This code throws a "Generic GDI error" exception on the 2nd save (Image2.save).

In my actual application, the image (after the first save) makes a detour through a database (varbinary(max) column) and back to a memory buffer and an image before the second save is called, with  no difference: the error still occurs.

For backward compatibility to some mighty old machines (stilll running Win2000!) it all has to happen in framework 2.0, but the error occurs on my development machine in 4.0 client profile just as well.

Dim Image1 As Image = Image.FromFile("C:\Users\Public\Pictures\Sample Pictures\Desert.jpg")

Dim Buffer1 As Byte()
Using MemoryStream1 As New IO.MemoryStream
    Image1.Save(MemoryStream1, System.Drawing.Imaging.ImageFormat.Jpeg)
    Buffer1 = MemoryStream1.ToArray
End Using

Dim Image2 As Image
Using MemoryStream2 As New IO.MemoryStream(Buffer1)
    Image2 = Image.FromStream(MemoryStream2)
End Using

Dim Buffer3 As Byte()
Using MemoryStream3 As New IO.MemoryStream
    Image2.Save(MemoryStream3, System.Drawing.Imaging.ImageFormat.Jpeg)
    Buffer3 = MemoryStream3.ToArray
End Using

LocalFileSettingsProvider throwing UnauthorizedAccessException

$
0
0

In my .NET client application I use the default settings provider with Scope=User and Roaming=True. This works fine in most environments, no matter if client or Terminal Server, except for a customer with a Citrix Terminal Server farm. Whenever

Properties.Settings.Default.Save()

is called, the following exception is thrown:

System.UnauthorizedAccessException: Attempted to perform an unauthorized operation.
   at System.Security.AccessControl.Win32.SetSecurityInfo(ResourceType type, String name, SafeHandle handle, SecurityInfos securityInformation, SecurityIdentifier owner, SecurityIdentifier group, GenericAcl sacl, GenericAcl dacl)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, SafeHandle handle, AccessControlSections includeSections, Object exceptionContext)
   at System.Security.AccessControl.NativeObjectSecurity.Persist(String name, AccessControlSections includeSections, Object exceptionContext)
   at System.Security.AccessControl.FileSystemSecurity.Persist(String fullPath)
   at System.Configuration.Internal.WriteFileContext.DuplicateTemplateAttributes (String source, String destination)
   at System.Configuration.Internal.WriteFileContext.DuplicateFileAttributes(String source, String destination)
   at System.Configuration.Internal.WriteFileContext.Complete(String filename, Boolean success)
   at System.Configuration.Internal.InternalConfigHost.StaticWriteCompleted(String streamName, Boolean success, Object writeContext, Boolean assertPermissions)
   at System.Configuration.Internal.DelegatingConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext, Boolean assertPermissions)
   at System.Configuration.ClientSettingsStore.ClientSettingsConfigurationHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.UpdateConfigHost.WriteCompleted(String streamName, Boolean success, Object writeContext)
   at System.Configuration.MgmtConfigurationRecord.SaveAs(String filename, ConfigurationSaveMode saveMode, Boolean forceUpdateAll)
   at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
   at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
   at System.Configuration.SettingsBase.SaveCore()
   at System.Configuration.SettingsBase.Save()

The reason for this exception:

  • System.Configuration.Internal.WriteFileContext writes a new copy (...newcfg) of the user settings in the user's roaming profile. Then, DuplicateTemplateAttributes tries to modify the ACLs of this file and explicitly set the ownership to the current user.
  • In the case of this customer this fails because the roaming profile is stored on a file share and the users have only Read and Change permissions, but not Full Control. They probably have Full Control in NTFS (because by default you are "Owner" of all files you create, and as the owner, you can do anything with the file no matter if you have "Full Control" explicitly set), but it seems like its blocked on the SMB share level.

This behavior doesn't make any sense to me: Given that the LocalFileSystemProvider always uses a private profile folder of the current user (local or roaming), there shouldn't be any need to mess with the ACLs and ownership.

Since WriteFileContext catches the exception, deletes the temporary .newcfg file and then rethrows, there is no way to simply catch the exception in my code and rename the file or somehow grab its content since it is already deleted when the exception is thrown.

I couldn't find any simple way to work around this issue except for implementing my own settings provider. For this, it seems like I even would have to rebuild things like the serialization part since all the System.Configuration stuff used for this is internal. And of course I don't want to break the currently used settings, so it looks like a ridiculous amount of code just to rebuild everything as it is with just "one line commented out" (setting the owner of the file).

Any ideas what else I could try?

There is no way the customer changes anything in its file share permissions...

Remark: This app is targeting .NET 2/3.5 CLR. Targeting .NET 4.0/4.5 produces the same exception with only the stack trace missing a few lines, so upgrading to a newer .NET version does not help.

How do we tell the .NET 4.0 CLR to use server garbage collection, when hosting the CLR ourselves?

$
0
0

We have a server app product.   This runs unmanaged code under COM+ for historical reasons.   There are also parts of the system which are managed code.

We host the CLR ourselves, using unmanaged hosting interfaces.   The reason for doing so is so that the app handles exceptions such as stack overflow gracefully, rather than following the default behaviour which is for the process to crash.

When we originally started hosting the.NET 2.0 CLR, we used the CorBindToRuntimeEx function.    Since moving up to .NET 4.0 however this function has been deprecated in favour of the sequence described in the MSDN article Loading the Common Language Runtime into a Process.

The reason I mention this is that the 2nd argument for CorBindToRuntimeEx specfies the GC flavor to use – ie whether to use workstation garbage collection, or server garbage collection.   Previously we supplied “svr” as the 2<sup>nd</sup> argument, indicating that we want to use server garbage collection.

Given that CorBindToRuntimeEx  is now deprecated, it is not clear to us how to indicate a preference for using server garbage collection when hosting the .NET 4.0 CLR.   Furthermore we can see that the default workstation garbage collection is in use, both by checking the GCSettings.IsServerGC property, and also by examining a full memory dump of the executing process.

Online there are suggestions to specify the GC flavor in the .config file like this:

<configuration>
  <runtime>
    <gcServer enabled="true"/>
  </runtime>
</configuration>

However, given that we previously had to specify the GC flavour in the call to CorBindToRuntimeEx, I would assume we still need to do so explicitly.   This is also suggested by a line in the MSDN article Fundamentals of Garbage Collection“You can also specify server garbage collection with unmanaged hosting interfaces”.

As things stand, the GCSettings.IsServerGC property always returns false – even if we make the above alteration to the .config file.   And note that this is seen when running on a quad-core machine.

Suggestions as to how we tell our app to use server garbage collection gratefully received.

Thanks in advance.

Ed Barrett

Doubt in Sql Query on Stored Procedure

$
0
0

Hi Friends,

             

In my project i want to filter total amount by FromDate and ToDate. and my doubt was i want to filter same amount <15 DifferenceDate , < 30 DifferenceDate....... <90 DifferenceDate

Ex: 

Total Amount    Date1  Date2 DifferenceDate    amount < 30    amount <60

2000001/01/2013 01/02/2013        60          10000(mu assumption) 20000(mu assumption)

here < 30 is 30 days less than difference date or 30 days less than Date2 

< 60 is 60 days is less than differencdate date or  greater than 30 and less than 60days

Please i need your help. i am in big head ache:) please send me Sql Query for this Doubt. post here or send to my mail id dinesh6690@gmail.com.. please send as soon as possible. thanks in advance . i have attached the sample


.NET


Viewing all 1710 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>