Reflections on System.Reflection: To GAC or not to GAC

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!

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Community Day 2010: The morning after

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?

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Open XML Package Editor Power Tool for Visual Studio 2010

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:

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

SharePoint 2010 Unit testing with pex and moles @ Community Day (Mechelen)

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!

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Community Day 2010 : June 24th 2010 in Utopolis Mechelen.

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

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

What do CC and BCC stand for?

I was chocked that I didn't knew the answer to this question immediately, offcourse we all know the result of putting someone in CC or BCC… :)

so here we go:

Cc
Cc is shorthand for Carbon copy . If you add a recipient's name to this box in an Outlook e-mail message, a copy of the message is sent to that recipient, and the recipient's name is visible to other recipients of the message.

Bcc
Bcc is shorthand for Blind carbon copy . If you add a recipient's name to this box in a mail message, a copy of the message is sent to that recipient, and the recipient's name is not visible to other recipients of the message. If the Bcc box isn't visible when you create a new message, you can add it.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)