-4

When i decompile a X.dll file i can't rebuild it and i receive the following errors


  • Severity Code Description Project File Line Suppression State Error CS1001 Identifier expected Library C:\Users\ ...\Managers\RpcHubManager.cs 52 Active

why the dotpeek create this strange code ,"o__SiteContainer6.<>p__Site7 " ,And what it mean ??,how can i solve this problem ??, thanks in advance

private void OnTimerElapsed(object sender)
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate(object n)
            {
                foreach (System.Collections.Generic.KeyValuePair<SessionManager, string> current in RpcHubManager.Dashboard_Connections)
                {
                    System.Collections.Generic.List<SymbolMinimizedDTO> updatedSymbolsPrices = this.trader_manager.GetUpdatedSymbolsPrices(current.Key, false);
                    if (RpcHubManager.<OnTimerElapsed>o__SiteContainer6.<>p__Site7 == null)
                    {
                        RpcHubManager.<OnTimerElapsed>o__SiteContainer6.<>p__Site7 = CallSite<Action<CallSite, object, string>>.Create(Binder.InvokeMember(CSharpBinderFlags.ResultDiscarded, "updateSymbols", null, typeof(RpcHubManager), new CSharpArgumentInfo[]
                        {
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                            CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null)
                        }));
                    }
                    RpcHubManager.<OnTimerElapsed>o__SiteContainer6.<>p__Site7.Target(RpcHubManager.<OnTimerElapsed>o__SiteContainer6.<>p__Site7, this.hubContext.Clients.Client(current.Value), Json.Encode(updatedSymbolsPrices));
                }
            });
        }
MMerhi
  • 39
  • 2
  • 2
    Well, first of all you should pick a book about C# and you will now why that code does not compile. – Adriano Repetti Feb 05 '16 at 15:50
  • 1
    I suspect this question is more to do with why this decompiler produces code that cannot be re-compiled - is this correct? – rhughes Feb 05 '16 at 15:52
  • @rhughes yes, exactly and what should i do in this situation, specially in this function to rebuild this library after modify it . – MMerhi Feb 05 '16 at 16:01
  • @adriano i know this isnt a correct syntax of c# and the compiler cannot build the project , but my question what is this code after decompile and how can fix it ?!!!! If you have an answer share it with us ... Thank you – MMerhi Feb 07 '16 at 08:27
  • I was little bit sarcastic, sorry. IL has less name limitations than higher level languages (because parser is simpler). C# compiler (but not only it!) generates *impossible* names for compiler generated code (lambdas, anonymous types, methods, enumerators and so on). Why? Because they are sure it will not conflict with code you wrote. Easy and effective. How to fix? Rename to valid names. Code will still look weird because it's generated by compiler but it will work – Adriano Repetti Feb 07 '16 at 08:36

1 Answers1

1

Your problem because IL (Common Intermediate Language) allows < and > symbols in variable names, but C# doesn't.

For example:

RpcHubManager.<OnTimerElapsed>o__SiteContainer6.<>p__Site7

It cannot be compiled because of <OnTimerElapsed>o__SiteContainer6 and <>p__Site7 name.

Replace it with

RpcHubManager.OnTimerElapsedo__SiteContainer6.p__Site7

and everything will works

Konstantin Zadiran
  • 1,485
  • 2
  • 22
  • 35