Low-Level Tracing - Cannot load type

Do you program directly PostSharp.CodeModel or another low-level API and need help? Put your questions here and we will try to answer.

Low-Level Tracing - Cannot load type

Postby LaurinS on Sun Dec 16, 2007 7:57 pm


hi guys
i love postsharp, it really changed the way i'm coding.
i always sufficed with postsharp.laos.
But know i want instrument my code aop like.
There are two postsharp samples trace and xtrace.
Both samples are a good initial point - but not powerful enough for the daily use.
The XTrace Sample is very easy to understand, especially if you know postsharp laos.
But if i want do a very detailed tracing i will loose a lot of performance because of the IoC calls to my methods.
So i decided to make a low-level weaver like the trace sample does.
I know have two assemblies, like the sample, and to test (at the moment) with only sligthly changed code...
so: YooApps.Diagnostics.Tracing and YooApps.Diagnostics.Tracing.Weaver
I copied these two files together with the pdb files and the YooApps.Diagnostics.Tracing.psplugin file to Program Files\Post Sharp 1.0\Plug Ins\
The content of the file is:
<?xml version="1.0" encoding="utf-8" ?>
<PlugIn xmlns="[url=http://schemas.postsharp.org/1.0/configuration][url=http://schemas.postsharp.org/1.0/configuration]http://schemas.postsharp.org/1.0/configuration[/url][/url]">
  <!--<SearchPath Directory="bin/{$Configuration}"/>-->
  <TaskType Name="YooApps.Diagnostics.Tracing"
     Implementation="YooApps.Diagnostics.Tracing.TracingTask, YooApps.Diagnostics.Tracing.Weaver">
    <Dependency TaskType="CodeWeaver"/>
  </TaskType>
</PlugIn>
So if i understood the comment in the example right i don't need to create a psproj file in my solution since i have copied my plug in into a registred postsharp search path.
Go on... i've created a console application referenced my public interface assembly and applied the trace attribute on a method.
now compiling my sample application always fails with the following exception:
------ Build started: Project: ConsoleApplication1, Configuration: Debug Any CPU ------
C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:"C:\Program Files\PostSharp 1.0\PostSharp.Public.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /reference:"..\..\..\..\..\Program Files\PostSharp 1.0\PlugIns\YooApps.Diagnostics.Tracing.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\ConsoleApplication1.exe /target:exe Program.cs Properties\AssemblyInfo.cs
Compile complete -- 0 errors, 0 warnings
PostSharp 1.0 [1.0.7.261] - Copyright (c) Gael Fraiteur and Community, 2005-2007.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error : Error while loading the type "YooApps.Diagnostics.Tracing.TracingTask, YooApps.Diagnostics.Tracing.Weaver": Could not load type 'YooApps.Diagnostics.Tracing.TracingTask' from assembly 'YooApps.Diagnostics.Tracing.Weaver'.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error : ===== PostSharp Assembly Binder =================
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Loading type {YooApps.Diagnostics.Tracing.TracingTask, YooApps.Diagnostics.Tracing.Weaver}.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Resolving the assembly name YooApps.Diagnostics.Tracing.Weaver.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Program Files\PostSharp 1.0\YooApps.Diagnostics.Tracing.Weaver.exe.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Program Files\PostSharp 1.0\YooApps.Diagnostics.Tracing.Weaver.dll.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Program Files\PostSharp 1.0\PlugIns\YooApps.Diagnostics.Tracing.Weaver.exe.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Program Files\PostSharp 1.0\PlugIns\YooApps.Diagnostics.Tracing.Weaver.dll.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  This file was found. It has version 1.0.0.0. This is the higher version probed so far.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Users\Developer\Desktop\ConsoleApplication1\ConsoleApplication1\bin\Debug\YooApps.Diagnostics.Tracing.Weaver.exe.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Users\Developer\Desktop\ConsoleApplication1\ConsoleApplication1\bin\Debug\YooApps.Diagnostics.Tracing.Weaver.dll.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Users\Developer\Desktop\ConsoleApplication1\ConsoleApplication1\obj\Debug\YooApps.Diagnostics.Tracing.Weaver.exe.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Probing the file C:\Users\Developer\Desktop\ConsoleApplication1\ConsoleApplication1\obj\Debug\YooApps.Diagnostics.Tracing.Weaver.dll.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  Loading assembly YooApps.Diagnostics.Tracing.Weaver version  (instead of 1.0.0.0) from C:\Program Files\PostSharp 1.0\PlugIns.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :  System.TypeLoadException: Could not load type 'YooApps.Diagnostics.Tracing.TracingTask' from assembly 'YooApps.Diagnostics.Tracing.Weaver'.
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.Type.GetType(String typeName, Boolean throwOnError)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.CodeModel.AssemblyLoadHelper.LoadType(String typeName)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error : =================================================
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error : Server stack trace:
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.CodeModel.AssemblyLoadHelper.LoadType(String typeName)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.Configuration.TaskTypeConfiguration.CreateInstance(XmlElement xml, Project context)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.Configuration.TaskTypeConfiguration.CreateInstance(Project configuration)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.TaskCollection.Add(String taskTypeName)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.Tasks.AutoDetectTask.Execute()
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.Project.ExecutePhase(String phase)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.Project.Execute()
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.PostSharpObject.InvokeProjects(ProjectInvocation[] projectInvocations)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error : Exception rethrown at [0]:
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.IPostSharpObject.InvokeProjects(ProjectInvocation[] projectInvocations)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.Extensibility.PostSharpObjectAccessor.InvokeProjects(ProjectInvocation[] projectInvocations)
C:\Program Files\MSBuild\PostSharp\PostSharp-1.0.targets(129,5): error :    at PostSharp.MSBuild.PostSharp.Execute() in p:\open\trunk\Core\PostSharp.MSBuild\PostSharp.cs:line 169
Done building project "ConsoleApplication1.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can anybody please help me?
big thanks in advance
kind regards
laurin
Laurin Stoll
LaurinS
 
Posts: 2
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Laurin Stoll

Re: Low-Level Tracing - Cannot load type

Postby gfraiteur on Sun Dec 16, 2007 8:44 pm

Hi Laurin,

It appears from the log that the file was found, but the type was not found in this assembly. No idea why. Is it public?

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 608
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org

Re: Low-Level Tracing - Cannot load type

Postby LaurinS on Mon Dec 17, 2007 9:26 am


Previously Gael Fraiteur wrote:
Hi Laurin,

It appears from the log that the file was found, but the type was not found in this assembly. No idea why. Is it public?

Gael

Ok thanks for your fast help. Sometimes i'm blind. I renamed a cs file, but not the class inside.

One further question, i'm sure you can help me:
I have a intern TraceSourceManager, which creates and holds my TraceSources for the application. Now the tracing attribute should inject the following code (your sample just uses Trace.WriteLine("..")):
TraceSourceManager.GetRegistredSource("DBSource").TraceInformation("DB created");
Now in the trace task i think i have to get the IMethod of this. But how can i do this?
I have this:
 this.TraceInformationMethod = module.FindMethod(typeof(TraceSourceManager).GetMethod("GetRegistredSource", new Type[] { typeof(string) }), BindingOptions.Default);
Or should i easly change the Method to TraceSourceManager.GetRegistrSource("DBSource","DB created"); ?

thanks in advance....
Laurin Stoll
LaurinS
 
Posts: 2
Joined: Sat Jan 12, 2008 4:55 pm
Full Name: Laurin Stoll

Re: Low-Level Tracing - Cannot load type

Postby gfraiteur on Sat Jan 19, 2008 11:03 pm

Laurin,

Sorry, it seems I skipped your last question.

I guess you found the answer...

Gael
Gael Fraiteur, project leader
got good support? consider donating to the project.
gfraiteur
Site Admin
 
Posts: 608
Joined: Tue Dec 18, 2007 3:09 pm
Full Name: Gael Fraiteur
Company: postsharp.org


Return to PostSharp Core