Sunday, November 25, 2012

Portable Class Library and Compability Problems

It's very common these days to develop applications to run in several different platforms. Conventionally, UI and logic are being seperated but still, porting is the problem. In MS enviroment, as you create a class library project (for example at .Net) and want to use it in somewhere else (like Windows Phone) it's not possible to use project directly. Instead, one by one, you have to port your code.

Portable Class Library is a solution to this from Microsoft, a project type that can be directly used at

- .Net
- Windows RT
- Silverlight
- XBox 360 XNA
- Windows Phone

solutions as reference. Of course it's not the field of roses without thorns and having strong restrictions to keep compability between all those platforms.

Portable Class Libraries Contrib is a project at this point to implement some important API's, especially at System.IO and System.Cryptography levels. Normally PCL does not support these API's and Contrib really does a good job about this. At the moment it brings these additional API's to Portable Class library,

Portable.Runtime
System.Net.WebUtility (for encoding/decoding HTML)
System.Diagnostics.Stopwatch
Extension 'Close' methods for IDisposable types

Portable.Reflection
Provides extension methods for retrieving a ICustomAttributeProvider from reflection objects, such as Type, MemberInfo, etc.

Portable.ComponentModel.Async
System.ComponentModel.BackgroundWorker
System.ComponentModel.AsyncOperation
System.ComponentModel.AsyncOperationManager

Portable.Security.Cryptography 
System.Security.Cryptography.AesManaged
System.Security.Cryptography.HMACSHA1
System.Security.Cryptography.HMACSHA256
System.Security.Cryptography.SHA1Managed
System.Security.Cryptography.SHA256Managed
System.Security.Cryptography.Rfc2898DeriveBytes

Portable.Security.Cryptography.ProtectedData (.NET 4.x, Windows Store and Windows Phone 7.5 only)
System.Security.Cryptography.ProtectedData

Tuesday, November 20, 2012

SharePoint 2010 : Failed To Load Receiver Assembly

When deploying the SharePoint solution from Visual Studio, you may sometimes face this error, especially after changing the Strong Name Key of projects.

In that case, you need to go to GAC, copy your project's public key token, and paste this value to your feature's "receiver assembly" string's proper place.

To find "receiver assembly" in properties window, you need to double click on feature and then this window appears.

Tuesday, June 21, 2011

Sharepoint 2010 : Deploying a WSP package to remote server easily

By using Sharepoint Management Console,

1) Uninstall-SPSolution -Identity package.wsp -WebApplication http://server
2) Remove-SPSolution –Identity package.wsp
3) Add-SPSolution "C:\blabla\package.wsp"
4) Install-SPSolution –Identity PernodTC.wsp –WebApplication http://server


Monday, June 20, 2011

CAML & C#

If you are querying a Sharepoint 2010 List with CAML using C#, sometimes you can face inconsistent results. One of the most popular ones is not working OrderBy statements. After querying the list in C# with OrderBy query, you may see that the incoming list is still in default order.

The solution here is simple: In case you are using Query tag in your query string, just remove it. Your querystring should start directly with Where or OrderBy tag and this should solve your problem.

If it still does not, you can add Type field to your OrderBy query. Type="Number" or Type="DateTime" helps CAML interpreter to understand howto sort it. (Well, it should automatically detect it from Sharepoint therotically, yes, but the real life is never easy in Sharepoint)

The last thing in your checklist can be that CAML is a case-sensitive language, you can think about checking your query syntax and capital letters.

Wednesday, June 1, 2011

Sharepoint 2010 and Session

Hello everybody,

It's a known thing that it's not that easy to start working with Sessions when developing custom webparts. It demands several modifications on server etc.

If you have jumped over that issue, you may face further ones about storing objects in Session.
One of the key elements here is being "Serializable" Even depending on your configuration, Sharepoint may allow you to use non-serialiazable classes in session or not.

But if you're facing "unknown error" in your session-using custom webpart, take a look at your session objects and be sure that all of them are serializable ones.

(You can define your all classes with [Serializable] attribute, by the way.)

Wednesday, December 8, 2010

Windows Azure & SQL Azure - A Fresh Start For Development

Microsoft is releasing some free accounts for Windows and SQL Azure these days for their partners. If you have your free accounts, then it's time to start developing something for the cloud.

To just to code a hello world application in Visual Studio 2010, ou need a Windows running IIS and ASP.NET. After installing service packs and cloud tools, it's very easy to create a C# cloud project and adding a ASP.NET web role application to it, then you'll have your first "Default.aspx" and you are free to modify it. After that, by using the management central of Azure (which looks pretty sexy) it's again very simple to publish the compiled application by right clicking on Cloud project and choosing "Publish".

After this step, maybe you need to also do something on SQL Azure.

Be careful: SQL Server Management Tools versions before than 2008 R2 are not fully compatible with SQL Azure, you cannot use "object explorer" though you can open a query window directly. Here the solution is downloading the latest SQL Server Management Studio Express for free.

After that connecting to SQL Azure is quite same like classic SQL Authentication method: From the management console of SQL Azure you'll learn the connection address for your database, username and password. That's it, then from the Management Studio you can create your tables and from ordinary .NET SQL classes, you can connect your application from your ASP.NET application which is compiled for Azure.

Rumors say that Microsoft is spending a very big effort on Bing, Mobile and Cloud these days as they want to keep their positions in the game against Google and Apple. My experience so far is, Windows and SQL Azure are extremely easy to start with, no need to worry.

Tuesday, December 22, 2009

SPFile Item Update Error: Operation is not valid due to the current state of the object.

It's very frustrating and can take a whole working day: You are trying to update a library (list) item from Sharepoint object model and getting this error continiously.

In fact, solution is simple: RunWithElevatedPrivileges is working buggy in Sharepoint 2007, so the best things is avoiding putting code in it as much as possible.

For instance, if you want to simply update "Title" of an item in your document library, it should appear like this;

SPFile FileToModify = null;
SPSite ElevatedSite = null;
SPWeb ElevatedWeb = null;

SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite Site = new SPSite(SiteCollectionUrl))
{
ElevatedWeb = Site.RootWeb;
ElevatedSite = Site;
}
});

SPItem Items = FileToModify.Item;
ElevatedSite.RootWeb.AllowUnsafeUpdates = true;
Items["Title"] = "new title";
FileToModify.Item.UpdateOverwriteVersion();
ElevatedSite.RootWeb.AllowUnsafeUpdates = false;
Returning = "ok";

--

Then you won't face any errors.

Sunday, February 22, 2009

Silverlight: MultScaleImage Catches All Events On Page

As the version 2.5, Deep Zoom Composer has a good option for beginner coders to play with it's output's source code, including the both XAML and C# ones. These days many people choose to start developing nice photo shows with it's original output.

However, if you decide to add extra functionality such as buttons etc., you may face that MultiScaleImage (the Deep Zoom area) catches every click on whole page, even it is located in a seperate canvas apart from other elements.

This problem is caused by the original output generator. By default, all mouse events are binded to page. Just go to your source code and modify this.MouseLeftButtonUp etc. events into msi.MouseLeftButtonUp. After this, MultiScaleImage will only catch its mouse events, not the unrelated ones.

Monday, January 26, 2009

Visual Studio crashes in every Silverlight exception

It is very frustrating for even the smallest exception, Visual Studio 2008 crashes immediately. Some people are started to get used to live with that, however, there is a very very simple solution for it.

Probably you are using Visual Studio 2008 in another language like German, French etc. Just switch it to English from Visual Studio settings. No reinstallation needed.

Then - magic. Your Visual Studio will break operation when an exception thrown and you will be able to read the exception cause.

I am really unhappy with Silverlight guys in Microsoft to let these simple errors exist in Silverlight development. This is not a beta version, this is Silverlight 2's official release.

Monday, September 22, 2008

Silverlight: "Open in Expression Blend" in Visual Studio 8 doesn't work

Microsoft Expression Blend 2.0 is not compatible with Visual Studio 8. When you try to edit your XAML page in Expression Blend, there are some errors saying that XAML page is not valid.

The solution is simple, you have to download and install Microsoft Expression Blend 2.5 June Preview. After installation, don't forget to run it once.

This should resolve the compability issue between Visual Studio and Expression Blend.

Wednesday, August 20, 2008

A first Silverlight step / Deep Zoom Composer

Since Microsoft decided to release millions of products, it has been confusing to follow all new names belong to them, but Silverlight is not one of these small tries: They take every chance to make Silverlight popular and in my opinon, they are on the right way. Every developer and designer around are aware of Silverlight these days.

If you want to have a very first step to Silverlight on your website, may something like this seem nice on yours;

Hard Rock Cafe Memorabilia

So, if you want to make a image gallery very similar to this, Microsoft has a small and nice tool, Deep Zoom Composer. It produces pure Silverlight and HTML output and it's very easy to build up a custom gallery for your needs. Seems fantasticly cute.

If you don't like Flash and Actionscript, Silverlight & .NET has many opportunities and deserves at least a try.

Tuesday, July 29, 2008

Beginner! An easy start to SharePoint / MOSS 2007 development

I was only experienced on Microsoft SharePoint as a basic user, which was a part of Small Business Server. When my boss came with a contract to develop a SharePoint system for a serious chain of compaines in Germany, I said ok, how difficult it can be?

However, one of the difficulties that SharePoint has is, setting up the development enviroment. You have to install many stuff on your computer, including Windows Server 2003, SharePoint Server, Visual Studio and probably SQL Server and so on.. Damn, only installation will take more than one day and setting up the user accounts, permissions etc. will probably take another one too.

Microsoft made a great work to kick this out : They've created a virtual image (VHD) file including a 30 days trial version of Windows Server 2003 with all configuration done; including a very well configured SharePoint Server, a basic version of Visual Studio 2005 and Microsoft Word etc. Here is the link :

http://www.microsoft.com/downloads/details.aspx?familyid=67f93dcb-ada8-4db5-a47b-df17e14b2c74&displaylang=en

Microsoft Virtual PC 2007 runs it so fast and stable. Of course Virtual PC 2007 is free to download too.

For my purposes I installed Visual Studio 2008, SharePoint Extensions for Visual Studio too. Magic! I liked it.

Notice : Suddenly Windows Server 2003 makes a Windows Update and it stops SharePoint to respond. It's better to turn Automatic Updates off in first run.