AngryHacker
AngryHacker

Reputation: 61596

Why does C# compiler kick in the second time?

I have a WinForm app. I compile it, double-click on it. Predictably, csc.exe kicks in, then goes away, and the application comes up.

I am assuming that at this point the application has been jitted, so no reason for csc.exe to kick in ever again.

I then quit the app and start it again. I see csc.exe kick in again.

What's going on?

Upvotes: 2

Views: 263

Answers (3)

desco
desco

Reputation: 16782

If you use XmlSerializer (directly or indirectly, i.e. when calling web services) then inside it generates temp assembly with serializer implementation: creates source file based on reflection information and compiles it with csc.exe. You can pre-generate serializers in development time by SGen.

Upvotes: 1

DevinB
DevinB

Reputation: 8316

If you are using serialization it needs to compile a dynamic assembly in order to create the classes required.

This means that most webservice calls will causes csc.exe to be invoked the first time. After that, the dynamic dll should be cache.

Upvotes: 2

Jon Skeet
Jon Skeet

Reputation: 1499660

Are you using serialization at all? I believe that will build a temporary assembly in some cases. Anything similar in your app?

Note that the JIT compiler is unrelated to csc, so that shouldn't be anything to do with it.

Upvotes: 4

Related Questions