Click on this icon to open the XML page.Tom Van Gaever - Blog
Search:   

Reflections on System.Reflection: To GAC or not to GAC 
Friday, July 16, 2010, 08:27 - General
Posted by Administrator
While creating a Visual Studio 2010 VSIX , I'm using reflection to inspect the project dll. While using this assembly's types, my addin creates other files in the solution... This enables me to generate code that would take me hours to write (I love this sentence!). But in this scenario I learned some things about reflector I haven't had any issues with before, probably because it wasn't in this particular scenario... I hope you didn't knew it already ;)

1) Load an assembly that is also deployed in the Global Assembly Cache or GAC
When you use the Assembly.LoadFrom(string assemblyFile) method, you'll notice that the assembly you load is not the assembly in the folder that you specified in your parameter, but it is the assembly that you have installed in your GAC. naturally when the assembly is not installed in the GAC, there is no issue ;)




But what if, like in my case, you would like to analyze a Type in a dll... And you would like to analyze the dll in the project bin folder and not the one in the GAC? Consider this quote regarding reflection:
You can load a disk-based assembly with the same identity as one in the GAC. If you tried this with LoadFrom or LoadFile, the GAC assembly is ALWAYS loaded.

In my case this is the not the behaviour I need, what I need is the Assembly.ReflectionOnlyLoad and the Assembly.ReflectionOnlyLoadFrom methods. It is important to know that these 2 methods only reflect the assembly, which basically means that you cannot load them... if you do try to load them, you'll receive an InvalidOperationException.

The solution?
By using the Assembly.ReflectionOnlyLoadFrom() method you are always analyzing/inspecting the dll you specified as a parameter.




2)the assembly dll is locked after using Assembly.ReflectionOnlyLoadFrom()
It seems that by using the LoadFrom methods will put a lock on the dll, this is not interesting for me because I would like to change the dll by building in in Visual Studio and then inspect it again... The resolution seems rather to easy!





The solution?
Assembly assembly = Assembly.ReflectionOnlyLoad(System.IO.File.ReadAllBytes(dlllocation));

More information:
http://msdn.microsoft.com/en-us/library ... embly.aspx
http://msdn.microsoft.com/en-us/library/0et80c7k.aspx
http://stackoverflow.com/questions/5701 ... ly-reflect
http://stackoverflow.com/questions/3058 ... ononlyload

Issue resolved, have a nice day!
1 comment ( 41 views )   |  permalink   |   ( 2.9 / 997 )
Community Day 2010: The morning after 
Friday, June 25, 2010, 08:32 - General
Posted by Administrator
Here are the slides and the code examples of my presentation yesterday, I tried to keep it as simple as possible just to prove you the power of the Pex and Moles framework and how it can help us unit test our SharePoint development.

Code examples:
http://www.tomvangaever.be/blog/comday2010/demo.zip

Slides:
http://www.tomvangaever.be/blog/comday2 ... lides.pptx

Pictures (More to come):







Reminder to myself, next time close your twitter client while presenting :)


Community Day 2010 was a success, see you next year?



add comment ( 5 views )   |  permalink   |  related link   |   ( 3 / 596 )
Open XML Package Editor Power Tool for Visual Studio 2010 
Wednesday, June 23, 2010, 11:45 - General
Posted by Administrator
Open XML is a wondefull technology to manipulate and create Office files, yesterday the VSTO team released the Open XML Package Editor Power Tool for VS 2010.. Thanks!

From the VSTO Team blog:

We are happy to announce that today we are releasing the Open XML Package Editor Power Tool for Visual Studio 2010 on Visual Studio Gallery. This Power Tool is a Visual Studio add-in that provides an easy way to parse and edit Open Packaging Conventions files, including Word, Excel and PowerPoint documents. This Power Tool enables you to do the following tasks:

•Open any Open XML Package file or XPS Package file directly in Visual Studio 2010.
•Browse the contents of Package files in a tree view.
•Open any XML part directly in Visual Studio's rich XML editor.
•Add or remove parts and relationships directly in the user interface.
•Import and export part contents to and from files.
•Detect when a Package file that is opened in Visual Studio is modified externally. The Power Tool prompts user to reload the file without having to close any open XML part editors.
•Create new Office Packages from a set of templates using Visual Studio's File > New dialog.



More information:
http://blogs.msdn.com/b/ericwhite/archi ... -2010.aspx
http://blogs.msdn.com/b/vsto/archive/20 ... wsignin1.0

Download:
http://www.microsoft.com/downloads/deta ... laylang=en

add comment ( 5 views )   |  permalink   |  related link   |   ( 2.9 / 544 )
SharePoint 2010 Unit testing with pex and moles @ Community Day (Mechelen) 
Wednesday, June 2, 2010, 08:43 - General
Posted by Administrator





SharePoint Services are known to be challenging to unit test, as it is not possible to execute the SharePoint Service without being connected to a live SharePoint site. For that reason, most of the tests written for SharePoint are actually integration tests as they need a live system to run. In order to properly unit test Sharepoint Services, we should be able to stub the dependencies out with a mocking framework, but even though the SharePoint objects in 2010 are no longer sealed, the constructors are still not public, which makes most mocking frameworks unusable. Pex contains a stubbing framework, called Moles that allows you to isolate, not only types in the SharePoint assemblies, but any assembly you want and detour any .NET method to your own delegates. Pex truly allows you to unit test Sharepoint Services.

See you there!
add comment ( 8 views )   |  permalink   |  related link   |   ( 3 / 532 )
Community Day 2010 : June 24th 2010 in Utopolis Mechelen.  
Tuesday, April 6, 2010, 15:14 - General
Posted by Administrator


Community Day is back with the Fourth Edition of this annual community event on Microsoft technologies!

Fourteen Microsoft User Groups combine their efforts to organize this unique networking and knowledge sharing
event. With so many new releases from Microsoft, the theme of Community Day 2010 is of course 2010: a new wave of products and technologies. This means that most sessions will be looking at Visual Studio 2010, Silverlight 4, Office 2010, SharePoint 2010, SQL Server 2008 R2, OCSR2...

Microsoft Community Day will take place on Thursday 24th June 2010 in Utopolis, Mechelen, where we will
bring together over 300 IT Pro’s and developers.

http://www.communityday.be/CD/
add comment ( 3 views )   |  permalink   |  related link   |   ( 3 / 360 )

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Next> Last>>