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

Run time error in upgrading application from .NET 2.0 to 4.5.1

$
0
0

Hi!

I'm trying to convert my application from .NET 2.0 to 4.5.1 but I got the with the run time version of my application.

Could not load file or assembly '...dll' or one of its dependencies.This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

How can I can get rid off this? Did I forgot something to add or modify on my Web.config?

The process of publishing the application is through local and the published files will be copy paste on the application server in Virtual Machine. 

Thanks in Advance,

Gynn


.Net Core execution flow - ProcessRequestNotification & FinishPipelineRequest getting called Four times per request.

$
0
0
Hi ,

This topic is in depth regarding architectural functionality of ASP.NET . 

I am having a small ASP.NET web application that displays a chart when it is loaded. I do helper function call injection in all the .Net functions that are coming to JITCompilation, So that all the .NET functions will call my helper functions when it is being called. Inside the helper function i log the function names. 

I am getting some strange observations when looking into the log file. 

For each request that is getting triggered , I am getting four "Hosting.PipelineRuntime:ProcessRequestNotification" and "HttpRuntime:FinishPipelineRequest" . When getting the URL inside those functions i am getting as follows. 

http://localhost:999/SaveToImage.aspx , http://localhost:999/ , http://localhost:999/ , http://localhost:999/ChartImg.axd?i=charts_0/chart_0_0.png&g=d8389079da824024a9ed19217e124715

And i also found that those four function calls have different HttpContext.Current object .  And the thread ID is same for 1st three function Calls and different for last function alone. 

Can any one explain me why this works like this.? This goes to the interior of .NET stuff. I am very much blank on this topic. 

Thanks,

./Selva

.Net Profiler - Choosing Entry Function and Exit function of a Request

$
0
0

Hi,

I need to choose the entry point function and exit function point of a .Net web application . What is the correct entry point of the function which should be common to both Classic and Integrated pipeline mode. 

The entry point and exit point should have the HttpContext.Current Object initialized. 

I choosed "System.Web.Hosting.PipelineRuntime:ProcessRequestNotification" as entry point and "FinishPipelineRequest" as exit point. But, for one single request  the entry point is getting called four times. And the ProcessRequestNotification does not present in "Classic" mode of pipeline request. 

So what should i choose as a better entry and exit point functions .?

Thanks 

./Selva


.Net Profiler - Passing the reference to Helper function as argument

$
0
0

Hi,


I am injecting my helper function into 

void FinishRequestNotification(IIS7WorkerRequest wr, HttpContext context, ref RequestNotificationStatus status)
Here I am need the 3rd argument to be passed as a argument(CEE_LDARG_3) to my helper function. How to do that.?

I can take the 2nd arguement by passing it as ELEMENT_TYPE_OBJECT as it's CorElementType.

But the third argument here is a reference . Can i use ELEMENT_TYPE_BYREF ?  But the web application is getting crashed (guess it cannot find the function probe).

I am giving the signature as 

COR_SIGNATURE sigFunctionProbe[] = {

IMAGE_CEE_CS_CALLCONV_DEFAULT,      

0x01,                              

ELEMENT_TYPE_VOID,                  

ELEMENT_TYPE_BYREF ,                

};

Looking forward for a correct way to pass the 3rd argument in the FinishRequestNotification(..)

Thanks ,

./Selva



Digital signature seems to remove Strong Name signature

$
0
0

I've an assembly in C++/CLI. This assembly is strong named, using Linker options, with a SN.exe generated Key.

However, the same strongly named assembly, if it is digitally signed, using signtool.exe, it seems to remove the strong name signature, indeed the strong name validation fails, and it does not install in the target machine's GAC.

Looking at this documentation : MSDN Documentation,

 - it says the strong name key is removed if post processing took, lime mt.exe (I'm not certain if signtool.exe falls in the same tools category)is used afterwards, but it says it does so only if CLR attributes are used. I user Linker options for strong naming.

Kindly advise on the process which can be used to strong name and digitally sign the C++/CLI assembly. Would I have to re-sign the assembly after digitally signing it?

Thanks,


CLR and RSA

$
0
0

Hi!

I have a problem: Trere is WinForm. This WinForm decrypts and encrypts text. I have made CLR with code from my WinForm (It's scalar function. It forms text and calls CLR for encrypt/decrypt text). But, when I call this function, I get error:

" A .NET Framework error occurred during execution of user-defined routine or aggregate "fn_fk1_getdata":   System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.    System.Security.Cryptography.CryptographicException:     at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)     at System.Security.Cryptography.Utils._EncryptKey(SafeKeyHandle hPubKey, Byte[] key)     at System.Security.Cryptography.RSACryptoServiceProvider.Encrypt(Byte[] rgb, Boolean fOAEP)     at UserDefinedFunctions.fn_fk1_getdata(String xml, String url) " 

Public and private Keys keeps local. 

What can I correct this problem?

Many thanks for the answer

PS I apologize for my English

Convert a .PFX file to .SNK file

$
0
0

Hi all,

Is it possible to convert an existing .pfx file to a .snk file with a public/private key in it ?
SN.EXE seems only be able to generate a new key pair .snk file.

Get web response from System.Exception (Status Code)

$
0
0

I have a method that fetches data from a web service and does some other functions offline . I have put this code within try/ catch statements . Following is an example of what I'm trying to do .

 Is there a way that I can explicitly identify whether the thrown exception is a WebException ?  (to get responce)     

private SampleMethod()
{
  try 
 {
// get data from web service
        // do other offline stuff
          }
 catch  (System.Exception ex)
          {
              if (// if exception is a web service exception,)
                {
                  // do these
                }

             else (// if exception is not a web exception)
           {
               //do these
           }
    }

}




# of current logical Threads are increasing constantly

$
0
0

My colleague is working on a client/server project. The server software is listening on a particular port by using TcpListener class. At first, I finds the server software has performance problem which consumes a lot of the CPU time. After reviewing the listening method, I find the problem and suggest one solution. Suddenly, I wonder it has other problems or not? So the performance monitor sets up for monitoring memory and thread usage. As time goes by, logical threads' count and physical threads' count are increased. However, process's thread's smallest value remains the same.

Even I read Lock and Thread Performance Counters without luck. Since the process' thread does not increased time after time and garbage collector does it job. The # of current logical threads shall keep in a range. Do I misunderstand the meaning of the current logical threads?

which net framework version application is using

$
0
0

Hi...

If I have frmw 4.0 client profile....and my app is targeting that. If I install frmw 4.5 my app will be still using 4.0 from client profile  or 4.0 from 4.5 installation?

Garbage collector causes Excel to crash

$
0
0

Hi,

I have an application designed to target .NET 4.0. The application registers some classes to COM.

I use these classes from Excel VBA.

When I throw a COMException from the application, Excel crashes, pointing to clr.dll (APPCRASH).

Now, in versions 4.0 and 4.5 everything works fine, I throw the exception, the error handler handles it and presents to the user in a message box. However, in 4.5.1 and 4.5.2, Excel would crash.

It is both Excel 2010 and 2013, and I have Windows 7 x64-bit installed, while the application itself s 32-bit.

Thanks in advance!

How do I verify that an assembly has an Enhanced Strong Name?

$
0
0

"sn -v myAssembly.dll" tells me if it has a strong name, but I don't know how to find out if it has an Enhanced Strong Name. A command-line solution is very much preferred, since that's easier to incorporate into our build system.

Thanks,

John


John Dallman

Enhanced strong naming from the command line

$
0
0

I found the information about how to do Enhanced Strong Naming from the command line at:

https://msdn.microsoft.com/en-us/library/hh415055(v=vs.110).aspx

That looks like just what I need. I want to sign with Enhanced Strong Naming (ESN), with key migration, because I want to be able to issue new versions of existing assemblies with ESN, and have them be recognised as the same assembly. Command-line is exactly what I need, because I'm working with a build environment that does not and cannot use Visual Studio projects, at all, in any way, and hence MSBuild techniques are no use to me.

However, there's a step in the instructions that looks wrong: Step 4 of "Signing with SHA-2, with Key Migration". It says:

4. Generate the parameters for a AssemblySignatureKeyAttribute attribute, and attach the attribute to the assembly.

  sn -ac IdentityPubKey.snk IdentityKey.snk SignaturePubKey.snk

I can't see how this does anything to the assembly. It's just working with the key files, and the assembly doesn't exist at this stage in the process anyway.

Can anyone explain this?

A secondary question: how can I verify that an assembly has an Enhanced Strong Name?


John Dallman

Profiling each and every methods in .Net web applications Cause overhead

$
0
0

I am doing .Net profiler by injecting helper function calls which will again call native function to log it. 

So each and every instrumented function will have the following as method body,

FunctionA()
{
//Entry Helper Function

..
..
..

//Exit Helper Function
}

From the above code , the entry and exit functions will have native function call. Inside the native function call i will log the fucntionID and time elapsed etc., 

The problem here is , my native function call (without doing any manipulations) is causing the overhead for about 15% per web request. My sample web request is raising some 2 million function calls and hence those many times the native call happens and that causes the overhead. 

The execution time for a web requests are as follows

1. without profiler attached - 5.6 seconds

2. with profiler attached and with native function calls (native functions are just empty functions) - 7 seconds

3. with profiler attached and commenting native function calls - 5.9 seconds. --> but the helper functions(C#) are called here. 

I used "SuppressUnmanagedCodeSecurity" in DllImport , so that the overhead was reduced from 30% to 15%. Still i don't know how to reduce the overhead. 

Is there any other ways to calculate the time elapsed and log the function calls for a web request instead of making two native calls(Entry and Exit) for each .Net function..?

Please let me know any other way to profile the .Net web requests.

./Selva


Trying to understand solutions with multiple projects that target different .NET framework versions

$
0
0

I have a solution with 3 projects.  Two of the projects target .NET framework 4.0 and the other one targets .NET framework 3.5. 

The two that target .NET 4.0 have reports that get generated and exported when they are called by the one that targets .NET 3.5.  

I want to have a better understanding of when it's okay to use projects in the same solution that target different versions of the .NET framework and when it's not.  Using the example above, the calling project targets an older version while the ones being "called" target newer versions.  

I think this is fine in this scenario because the older "calling" one is just rendering the reports from the others programmatically and not trying to use a .NET feature that was added to the framework after 3.5.  I wonder if this would be true, if I was trying to use a .NET 4.0 feature in the older 3.5 project though.

When is it necessary to ensure all projects in the same solution target the same version of the .NET framework and when isn't it?  Can a project that targets an older version always call code from another project that targets a newer version?  I assume the answer to the second question is probably no, but I'm curious if anyone has any opinions on this.

 

How to remove properties and personal information from a file (programmatically)

$
0
0

Hi everyone.

When you click with right button in some file, and choose "properties", you can see the personal information of the creator in details tabs, like the screen below:

001

All kind of files has different type of properties: .mp3, .cdr, .doc, .tiff, etc...

But if you click in "Remove Properties and Personal Information" in this same screen, you will see this:

002

How you see, Windows allow to you remove everything, just selecting all and clicking in "OK".

What I ask is: how I do this same thing in C#? The default .NET framework don´t give access to this kind of action. This is a SO action, right?

I tryed to use the "shelld32.dll" to do it, but it just allow to read the info, not setting.
The Attributes Files info don´t work too.

Anyone know what SO DLL I can use to do the same action tha SO do?

Ty!

RSACryptoServiceProvider error(s)

$
0
0

From a Windows From desktop application, Visual Studio 2008, framework 3.5

I get errors trying to decrypt a message. I tried it different ways based on articles I found on the net, but I still have the same issues

Heres common code to both approaches:

 

UserCert

X509Certificate2UI
.SelectFromCollection(.....)

RSACryptoServiceProvider

pk = (RSACryptoServiceProvider)UserCert.PrivateKey;

....

UserName = "Some Text";

...

byte

[] dcn = Encrypt(UserName, pkpub);

...

 

Try #1

 

string

ptst = UserCert.PrivateKey.ToXmlString(true);  <-----------------  throws Key not valid for use in specified state

byte

[] data = Encoding.UTF8.GetBytes(dataIn);

byte[] decrypted;

using (var rsaPublicPrivate = newRSACryptoServiceProvider())

{

rsaPublicPrivate.FromXmlString(key);

decrypted = rsaPublicPrivate.Decrypt(data,

false);

}

> mscorlib.dll!System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(int hr = -2146893813) Line 114 C#
  mscorlib.dll!System.Security.Cryptography.RSACryptoServiceProvider.ExportParameters(bool includePrivateParameters) Line 211 C#
  mscorlib.dll!System.Security.Cryptography.RSA.ToXmlString(bool includePrivateParameters = true) Line 138 C#

 

Try #2 

 

RSACryptoServiceProvider

pk = (RSACryptoServiceProvider)UserCert.PrivateKey;

byte

[] decrypted;

decrypted = pk.Decrypt(data,

true);  <-------------- throws Invalid type specified.

 

  mscorlib.dll!System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(int hr = -2146893814) Line 114 C#
  mscorlib.dll!System.Security.Cryptography.RSACryptoServiceProvider.KeySize.get() Line 143 + 0xd bytes C#
  mscorlib.dll!System.Security.Cryptography.RSACryptoServiceProvider.Decrypt(byte[] rgb = {byte[128]}, bool fOAEP = true) Line 340 + 0xa bytes C#

Service Fails to start whenever I have code inside it to access app.config using configuration manager

$
0
0

Hello,

I have coded a windows service. It runs, starts, stops or works fine. But I am using hard coded configurable values in the code, which is not a good practice. I would rather use the App.config file. Except, I am unable to. Whenever I modify the App.config, for example as shown below..

<configuration>

  <appSettings>

    <addkey="production"value="y"/>

  </appSettings>

and then in my source code files try to access the configuration setting, for example with code

if (ConfigurationManager.AppSettings["production"] == "y")

my service fails to start. It gives me the following error message, when I try to start it..

"Windows could not start the <ServiceNameHere< service on Local Computer

Error 1053: The service did not respond to the start or control request in a timely fashion."

Please note I am able to compile & install the service (using installutil command), just fine. The problem is that it never starts.

Help Appreciated. thank you


diana4

"The application failed to initialize properly (0xc0000022)." getting this error when trying to invoke an application

$
0
0

I am runnning silktest application but sometimes while invoking the runtime.exe getting error "The application failed to initialize properly (0xc0000022)."

How to debug why this error is coming internitently.

Injecting the Helper function call with a Condition ?

$
0
0

Hi,

I have a severe problem now. I need to handle the case where in a web request, few functions are being called more than a million times added together. 

SomeDotNetFunction()
{
//HelperFunc Enter Call
..
..
//helper Func Exit Call
}

The helper functions will again call the C++ functions to log. 

As my profiler injects two helper functions (one at entry and one for exit) there will be double the number of helper function calls that will again call my native function.

In such cases I am getting a massive overhead .

Is there any possible way to tell the SomeDotNetFunction() Not to call the helper functions when it's calls exceeds more than thousand..? 

I tried maintaining a map to count the number of function calls in both C++ and C#. Neither of the approaches works. It caused overhead only. I am sure that some one would have faced this similar case. 

I hope for a best solution.

./Selva

Viewing all 1710 articles
Browse latest View live


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