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

Is running C++ dlls supprted in any ASP.net website or web service?

$
0
0

We have the need to run in house C++ dll's (have source code) along with 3rd party dll's (No source code) in the web.

Is this supported and possible?

Would prefer to run this in a Azure C# Web App or C# API App

Open to running on Azure VM web server or none cloud self hosted web server.

Nothing I have tried so far has worked just keep getting file or dependency not found errors.



Educational Material for programming C++ through C# forms

$
0
0

To whom it may concern:

I would like to know if there is a manual or book that can explain to me the interfacing of C# forms to C++ applications through Visual C++ platform.

Dylan T. Rogers

Invalid IL program detected in Event Log - .Net Profiler

$
0
0

I am injecting the entry and exit function call ILs into the .Net code from my profiler. 

The signature of the function that i inject is 

COR_SIGNATURE sigFunctionProbe4[] = {
		IMAGE_CEE_CS_CALLCONV_DEFAULT,      // default calling convention
		0x03,
		ELEMENT_TYPE_VOID,
		ELEMENT_TYPE_U8,
		ELEMENT_TYPE_I4,
		ELEMENT_TYPE_I4,
	};

and the corresponding function's definition in the helper assembly is 

public static void EnterFunction(UInt64 fID, int flag1, int flag2)
{
..
..
}

The application that i am profiling is "Citrix Director" . In this case when my profiler gets attached to the application  , the application does not even log in and throws an error in EventLog ("the w3wp.exe process is not crashed") as attached in the image 

But if i Add en extra argument in the signature of the method , then everything works fine - The highly confusing part. 

Works Fine with the following 

COR_SIGNATURE sigFunctionProbe4[] = {
		IMAGE_CEE_CS_CALLCONV_DEFAULT,      // default calling convention
		0x04,
		ELEMENT_TYPE_VOID,
		ELEMENT_TYPE_U8,
		ELEMENT_TYPE_I4,
		ELEMENT_TYPE_I4,
		ELEMENT_TYPE_I4,
	};

public static void EnterFunction(UInt64 fID, int flag1, int flag2, int flag3)
{
..
..
}

Should i inject an helper function call with four arguments only..? (this happens only for profiling few applications - for many other web applications profiler works flawlessly)

Windows Service start-up parameters

$
0
0

Hi, 

I have a windows service performing log folder monitoring. The service at start-up has to perform slightly different job, depending on whether it's started by Windows during computer/OS boot process, or by a user from the SCM. 

So my question if there is a way to somehow distinguish the Windows automatic boot from user interaction?  

Thanks a lot!


 

PInvoking ReadFileEx

$
0
0

I'm trying to use PInvoke to call ReadEx, but I haven't been able to figure out exactly how to do it.

The signature for ReadFileEx contains a callback delegate, which is provided as System.Threading.IOCompletionCallback. However, ALL the pack routines also require a completion callback. I've tried every combination, and nothing works.

vb6 com server lnvoking .net 2.0 ccw failed

$
0
0

I need some suggestions as I am trying to isolate a problem in some very old code in old machine. Rewriting is out of the question. I only have small pieces of the whole puzzle. Therefore, please bear with me!!

1. We have com+ server running vb6 classes in one instance without recycling setting. It was running fine for years in win2003 OS within virtual machine.

2. In the last few months, the vb6 classes running in com+ server reported "out of memory" error. Once this error occurred, some methods (in different vb6 classes) always reported this error and others are running fine. Physical memory and dllhost.exe memory usage are both reasonable. The only way to fix it is to recycle the com+ server application.

3. We are in the midst of pinpointing the line in vb6 raising the problem. I reviewed those methods reporting errors. Following is what caught my eyes. They both invoke CCW coded in .net 2.0 framework dll. At least one the dll has very strong error reporting, but there is reported .net error correlated in time with the vb6 "out of memory" error.

4. There is a lot of info in the internet about CCW mscoree.dll not disposing .net objects as expected. Will such issue cause my observation inside a long running com+ server application?

Thanks in advance

EventLog.Level issue

$
0
0

Hello, 

I am writing an application that has to monitor EventLog for SharePoint related entries in particular. I am subscribing to and processing System.Diagnostics.EventLog.EntryWritten event. 

The problem is that System.Diagnostics.EventLogEntryType enumeration which defines theLevel column in the EventViewer, doesn't contain "Critical".  What I am receiving in theEntryWrittenEventArgs.Entry.EntryType for "Critical" SharePoint events is 0.

Is there any way to get the actual Level, not just zero? This is not SharePoint specific thing in fact, some other applications also use their own levels...

Thanks a lot!

'System.OutOfMemoryException'

$
0
0

I am getting the following error when I tried to build one of projects. I wonder how to fix this error.

Error 16 The "GenerateResource" task failed unexpectedly. System.OutOfMemoryException

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String filename, String classname, Boolean publicClass)

at Microsoft.Build.Tasks.GenerateResource.Execute()

at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound)


Multiple controls in a DLL using Visual Studio

$
0
0

I have a series of custom user controls (ASCX files) which have been tested and are confirmed to be in working order. Using the method provided by Microsoft (https://msdn.microsoft.com/en-us/library/aa479318.aspx) I have successfully managed to create a DLL for each control and reuse them in several different applications.

What I would like to do now is to combine the controls into a single DLL, as importing 5 or so DLL's into each application can be a bit of a hassle, but this is where things tend to get interesting. When I combine the controls by using ILMerge I get results included but not limited to the following:

  • Controls failing to render entirely
  • Controls corrupting their Javascript so it shows as raw HTML
  • String resource errors

I suspect this is due to selecting my primary assembly incorrectly but I receive an error no matter which DLL I select as the primary assembly. Therefore my question is whether it is indeed possible to combine several custom controls into a solitary DLL and if so how? All of my controls are in a single solution and use a single Javascript and CSS file.

Any advice is appreciated!

Microsoft Bot Framework Channel Emulator not starting

$
0
0

Hi all,

I'm trying to run the Microsoft Bot Emulator and I'm getting this error -

ERROR SUMMARY
 Below is a summary of the errors, details of these errors are listed later in the log.
 * Activation of http://download.botframework.com/bf-v3/tools/emulator/Bot%20Framework%20Channel%20Emulator.application resulted in exception. Following failure messages were detected:
  + Value does not fall within the expected range.

I believe it's got something to do with the .NET version. I'm sure I'm having 4.6, but I'm not able to make out why this isn't starting.

You can download the Bot Framework Channel Emulator from - https://download.botframework.com/bf-v3/tools/emulator/publish.htm

Please help.

Ajax Filter issue

$
0
0

Hi, I am trying to finish a system that someone left in the middle of writing and I have no experience in this language. We have a Filter on a form which is not working. I have started to debug the filter and it is saying that the issue is with the Ajax code (I had to allow the option "Show not my code" to turn on) to see it. can someone tell me if there is something wrong with this code. 

                $.ajax({
                    type: "Post",
                    url: '/PatientManager/Filter',
                    data: theData,
                    success: getListSuccess,
                    error: getListFail
                });

Thanks

Why doesn't .NET 4.5 warn me when running a .NET 4.6 application

$
0
0

We have an application which uses .NET 4.6 as target framework. It turns out that the application can be started when having .NET 4.5 installed. However lates on it could crash when executing certain code which doesn't seem to be compatible with 4.5.

It would have been nice if the framework would tell the user that the application requires a newer version of the framework. This would save us a lot of time troubleshooting mysterious crashes.

Quicken Launch Error

$
0
0

I have attempted to load Quicken 2016 Home & Business; the application installs without error, but fails to launch.

I can successfully load and run 2013 and prior versions, but have encountered this problem beginning with their 2014 version. I am not a developer, but have had some software and systems experience.

I have exhausted Intuit support and they do not to have the ability to pass this to anyone more advanced.  If it at all possible I would like to resolve this without the shotgun approach of reloading the system.


Below is my system info, the windows application event log error messages and, and output from Windows Debugger.
 

My System Info:

OS Name    Microsoft Windows 7 Professional
Version    6.1.7601 Service Pack 1 Build 7601
Other OS Description     Not Available
OS Manufacturer    Microsoft Corporation
System Manufacturer    Hewlett-Packard
System Model    HP EliteBook 8560p
System Type    x64-based PC
Processor    Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz, 2501 Mhz, 2 Core(s), 4 Logical Processor(s)
BIOS Version/Date    Hewlett-Packard 68SCF Ver. F.42, 7/15/2013
SMBIOS Version    2.6
Windows Directory    C:\Windows
System Directory    C:\Windows\system32
Boot Device    \Device\HarddiskVolume1
Locale    United States
Hardware Abstraction Layer    Version = "6.1.7601.17514"
Time Zone    Mountain Daylight Time
Installed Physical Memory (RAM)    4.00 GB
Total Physical Memory    3.95 GB
Available Physical Memory    1.21 GB
Total Virtual Memory    7.90 GB
Available Virtual Memory    3.87 GB
Page File Space    3.95 GB
Page File    C:\pagefile.sys


Windows Event Log:

Event 1026, .NET Runtime

Application: qw.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.BadImageFormatException
   at QuickenWindow.SplashScreen..ctor()
   at QuickenWindow.Program.ShowSplash()
   at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()



Event 1000, Application Error

Faulting application name: qw.exe, version: 25.1.2.10, time stamp: 0x5640d978
Faulting module name: KERNELBASE.dll, version: 6.1.7601.23418, time stamp: 0x5708a7e4
Exception code: 0xe0434352
Fault offset: 0x0000c54f
Faulting process id: 0x2050
Faulting application start time: 0x01d1f3e8036cbbcf
Faulting application path: C:\Program Files (x86)\Quicken\qw.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: 41f44549-5fdb-11e6-801a-463500000031


Microsoft (R) Windows Debugger Version 10.0.14321.1024 X86
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: "C:\Program Files (x86)\Quicken\qw.exe"
Symbol search path is: srv*
Executable search path is:
ModLoad: 01370000 013e4000   qw.exe  
ModLoad: 77cb0000 77e30000   ntdll.dll
ModLoad: 6df00000 6df4a000   C:\Windows\SysWOW64\MSCOREE.DLL
ModLoad: 76470000 76580000   C:\Windows\syswow64\KERNEL32.dll
ModLoad: 75f40000 75f87000   C:\Windows\syswow64\KERNELBASE.dll
(1ae4.1b80): Break instruction exception - code 80000003 (first chance)
eax=00000000 ebx=00000000 ecx=48910000 edx=000edcd8 esi=fffffffe edi=00000000
eip=77d417a4 esp=002ffaec ebp=002ffb18 iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000246
ntdll!LdrpDoDebuggerBreak+0x2c:
77d417a4 cc              int     3


Moving assembly from GAC to applocal hits a CLR exception.

$
0
0

I have moved an assembly out of the GAC and into an applocal location. The assembly uses the CLR and the expression host for generating code on the fly. When it tries to generate the code, it hits an Exception in the CLR and crashes. I am assuming the issue is the GAC gets Fulltrust by default, my app location does not.

I have tried adding a custom configuration file that grants fulltrust to all assemblies, but I still get the error.

I am not sure what I need to do to get the DLL to function, looking for any advice.

Here is the error:

 

Thanks,
Brad


Brad Syputa, Microsoft SQL Server Business Intelligence This posting is provided ASIS with no warranties.

Method caching of dynamic objects

$
0
0

I instantiate a dynamic object by using the Activator.CreateInstance() method, e.g:
dynamic dynObject = Activator.CreateInstance(Type.GetTypeFromProgID("SomeProgID"));

The object created is a COM object with lots of methods (hundreds) defined and it takes quite some time to run a method the first time due to the runtime going through the objects capabilities (methods etc.) and caching them, in this case approx. 1500ms.

Say I need less than 10% of the objects offered interface, is it possible to restrict the runtime to cache only a specified set of methods, e.g. by a method pattern or similar ? (possibly increase the cache later if needed).

I have tried using reflection instead and it is initially faster, later slower and of course much more complex and error prone.


Windows 10 Annivesary update with IE 11 breaks .NET control hosting

$
0
0

I realize this scenario has been on shaky ground for some time, but we have an application that does not run on an intranet, that requires the hosting of a .NET control to interact with some hardware that is not supported through browser API's. We are in the process of rewriting this application from scratch, but it has taken longer than expected. In the meantime we have to support the existing application.

We have so far always been able to work around changes to IE that interfered with the ability to host the .NET controls, but this latest update so far has us stumped. We can put our site in compatibility mode, and it will work. At least one of our customers has indicated that this is not an acceptable solution so we are trying to work around it. Specifying an X-UA-Compatible meta tag on the page also works, but only if we push the mode all the way to IE=7. Previous to this recent change on Windows 10 anniversary update we could run without specifying a legacy document mode or a setting the URL up in compatibility mode in the browser.

Can someone explain to me what was changed? Are there other settings that allow us to work around this problem? Is there any way to make this work while specifying IE=10 as the document mode so the rest of the page doesn't have rendering issues?

What changed in 4.5.1 that made FCB issue with Win Server 2008/R2 more pronounced?

$
0
0

After updating our servers to .NET framework 4.5.1, our application will just stop working after sometime. Our application uses dynamically loaded DLL through reflection. Proc Mon and FusLogVw show that the DLLs are loaded correctly, but at the point where the code tries to use Invoke (a member or a method), the application generates a System.Reflection.TargetInvocationException. Since our application is located on a mapped network drive, I stumbled upon KB2536487 (https://support.microsoft.com/en-us/kb/2536487). 

Using WinDbg;

(6d4c.6610): In-page I/O error ffffffffc00000c4 - code c0000006 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=047639e4 ebx=000039e4 ecx=00729ffc edx=000039e4 esi=047639e4 edi=00729ffc
eip=6cf19e56 esp=002abc10 ebp=002abc5c iopl=0         nv up ei pl nz na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00210206
clr!PEDecoder::CheckILMethod+0x43:
6cf19e56 8a06            mov     al,byte ptr [esi]          ds:002b:047639e4=??
0:000> g

When I Googled In-page I/O error, they all pointed to the FCB issue when multiple users reference the same file on a network drive. We only have two or three occurrences of this in a year when running on .NET Framework 4.0, but after upgrading to 4.5.1 or higher, we are seeing the problem almost every day now. Only reboot can clear the error for a short time. So I'm wondering if something in 4.5.1 and up that has changed that made the FCB issue with Windows Server 2008/R2 more pronounced.


.NET Framework error on startup

$
0
0

Receiving the following at startup:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Service name  contains invalid characters, is empty, or is too long (max length = 80).
   at System.ServiceProcess.ServiceControllerPermissionEntry..ctor(ServiceControllerPermissionAccess permissionAccess, String machineName, String serviceName)
   at System.ServiceProcess.ServiceControllerPermission..ctor(ServiceControllerPermissionAccess permissionAccess, String machineName, String serviceName)
   at System.ServiceProcess.ServiceController.GenerateStatus()
   at System.ServiceProcess.ServiceController.get_Status()
   at urgent.Form1.service_check()
   at urgent.Form1.Form1_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
urgent
    Assembly Version: 0.3.0.6
    Win32 Version: 0.3.0.6
    CodeBase: file:///C:/Program%20Files/GIGABYTE/Smart%20Update/urgent.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.ServiceProcess
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1586.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.ServiceProcess/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.ServiceProcess.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Any help you can provide would be greatly appreciated.

MPEG's wont play

$
0
0

I am saving MPEG files from an old windows 7 computer to a new windows computer.  When I try to open the files in the new computer i get a black screen.  I can hear the audio but not the video portion.  What can I do the get these to play correctly????

Chris

Programmaticaly create a self-signed certificate with SHA256 and not SHA1

$
0
0

I need to create a self signed certificate in code. I have a working example using Security.Cryptography.dll from http://clrsecurity.codeplex.com but it uses SHA1 and I need to use SHA256.

I've updated the provided example to use SHA256 algorithm but I don't know how to force it to use "Microsoft Enhanced RSA and AES Cryptographic Provider" as CSP.

When accessing the privateKey of the generated certificate I get a System.Security.Cryptography.CryptographicException "Invalid provider type specified."

   at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)
   at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
   at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()
   at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
   at System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()


I've read a lot of posts on this subject without finding a way to do this. I've also tried calling the Native API Crypt32.dll, CertCreateSelfSignCertificate but it only gives me SHA1 and when I try to pass in the following parameters:

_In_opt_ PCRYPT_KEY_PROV_INFO            pKeyProvInfo,

_In_opt_ PCRYPT_ALGORITHM_IDENTIFIER     pSignatureAlgorithm

It fails with an exception - probably because the structure I created isn't correct but I'm finding the documentation a bit limited.

So that is why my current approach is with Security.Cryptography.dll as it seems easier but I can't figure out how to force it to use the provider it needs for SHA256.

Below is the code:

private void CreateCertificate(string fileName, string password)
	{
		X509Certificate2 cert = null;
		var name = new X500DistinguishedName("cn=" + WindowsIdentity.GetCurrent().Name);
		// Generate Key
		CngKeyCreationParameters keyParams = new CngKeyCreationParameters();
		keyParams.KeyUsage = CngKeyUsages.Signing;
		keyParams.Provider = CngProvider.MicrosoftSoftwareKeyStorageProvider;
		//keyParams.Provider = new CngProvider("Microsoft Enhanced RSA and AES Cryptographic Provider");
		keyParams.ExportPolicy = CngExportPolicies.AllowExport;
		keyParams.Parameters.Add(new CngProperty("Length", BitConverter.GetBytes(2048), CngPropertyOptions.None));

		CngKey newKey = CngKey.Create(CngAlgorithm2.Rsa, Guid.NewGuid().ToString(), keyParams);

		// Init certificate
		X509CertificateCreationParameters certParams = new X509CertificateCreationParameters(name);
		certParams.StartTime = DateTime.Today.AddDays(-1);
		certParams.EndTime = DateTime.Today.AddYears(30);
		certParams.SignatureAlgorithm = X509CertificateSignatureAlgorithm.RsaSha256;
		// Create cert
		cert = newKey.CreateSelfSignedCertificate(certParams);

		using (Stream outputStream = File.Create(fileName))
		{
			byte[] pfx = cert.Export(X509ContentType.Pfx, password);
			outputStream.Write(pfx, 0, pfx.Length);
			outputStream.Close();
		}
	}

Please note that I can't use makecert, openssl or powershell since I need to do it in c# only.



Karin, Stockholm

Viewing all 1710 articles
Browse latest View live