Posts

Showing posts with the label Visual Studio

How to embed an image into your WPF application

If you are building an WPF application you could need images as background or as buttons or whatever. With your  first build or debug you will see the images will be stored in a folder that should not change. If you change it the application cannot find its images and crashes. So if your installing this application you will need to make sure the pictures are in the exact place. There are possibilities to make the path of the path dynamic, but even that is not the best solution.  So how to make sure your files will be where your application will be.  The solution is to embed the images, but how..? Of course there are some hacks you need to know. First of all you need to right click on your project in Visual Studio. Go to "Properties" and then "Resources". Add a resource and choose existing file. Choose your image.

register and debug provider hosted SharePoint Online Add Ins with tenant full controll

It is a while since Microsoft launched the Add In (or App) architecture for SharePoint, but there are still things they change or we are not familiar with. In August 2016 there was a change in giving tenant permissions to provider hosted Add Ins using app-only mode and Azure Access Control Service (ACS).

How to support multiple languages in WPF

Image
If you are developing many solutions for many costomer, one day one of them will require a multilingual WPF-solution. So there is the question: how to make a WPF form multilingual? At first you need at least two languages that you want to support. You can add some other languages at the end very easy. First of all create a folder in your project and call it "Languages", to keep an overview. Once it is done you can create Resource Dictionaries in this folder. You can call them however you want, but make sure you can assign them to the language. You can use language codes (like "en-us") or you can call it like the language is called. At the end it can look like this:

SharePoint 2013 app - get data from the SharePoint

Image
For safety reasons apps are seperated from the SharePoint where they are installed on. Apps are installed on other domains and that is how the seperation works. Apps can't contact the SharePoint, because Cross-Site-Scriptingis blocking it. But there is still a way to get data from the SharePoint and with this way comes a permission concept into the app world. Permissions There is a library, called the Cross Domain Library, that allows to communicate with a SharePoint from app site. This library is aviable on every SharePoint 2013 and is easy to call. But wait.. if it is so easy to call a library that can get SharePoint data it is not saver than before. This library contains more than communication.. it authentificates the app against the SharePoint and asks for permissions. This happens right after the installation of the app. The installing user will be asked to grand permissions for the app. But how does the app know what permissions are needed? Asking for permissions is you...

Basics for SharePoint 2013 app development

Image
The biggest innovation in SharePoint 2013 is the app-architecture. With this innovation it is possible to install applications (apps) on a SharePoint. This applications can be developed by yourself or you can buy them in the SharePoint Store. They are totally detached of the SharePoint and got their own area. They can contain own lists, have own sites with custom code and they have their own interfaces. But it is possible to communicate with the SharePoint. My first app To develop an app you need Visual Studio 2012 or above and a development SharePoint. To begin start Visual Studio as administrator and click 'New project...'. A mask opens where you can choose a template. Go to 'Templates' → 'Visual C#' → 'Office/SharePoint' → 'Apps' and select 'App for SharePoint'.

SharePoint 2013 WebPart with custom properties

Image
If you created a WebPart for SharePoint 2013 and you want the user to customize it, you will need properties. Setting them up is not that easy as you think. You need to edit two files. Lets begin with the <yourWebPart>.ascx.cs file. What you will do there is setting up the propertiesobjects. Later you can use them to read the values the user typed in. I make a difference between two kind of properties: 'easy' and 'not that easy properties'. I do not call it 'not that easy', because it is hard to use, I call it that way because you need a line of code more. An easy propertiy would be a textfield. The code you need to add would look like this. 1 2 3 4 5 6 7 [WebBrowsable(true), WebDisplayName( "<youtDisplayname>" ), WebDescription( "<yourDescription>" ), Personalizable(PersonalizationScope.Shared), Category( "<yourCategoryname>" )] public string customTextProperty { get ; set ; }

DragAndDrop in Outlook - is it a mail, an attachment or a file?

If you are developing an addin for outlook and you are building a drag and drop able control, you will need to check what kind of data droped in. In the following code I made differences between those three types: files from the filesystem, mails out of Outlook and attachments that came from mails in Outlook. I used the DragEventArgs to figure out what was droped and then I handle each way a bit different.

The project type is not supported error

Image
I tryed to open a Visual Studio project on another enviroment and ran into an error. A dialog poped up and looked like this. The Output Window sait 'The project type is not supported by this installation.'. So Visual Studio was not able to read the projectfiles. The reason is that the project templates are not installed.

Create CustomTaskPanes in Office AddIns with C#

Image
To create you own workspace in an Office application like Outlook you need a CustomTaskPane . To call a CustomTaskPane you need to create at first a UserControl . In that UserControl you can build your own layout. After that you need to create a class called TaskPanes. This class contains two functions, one to create a CustomTaskPane and one to remove it. In the create-function you are creating an object of your UserControl and a CustomTaskPane-object. By creating the CustomTaskPane you are giving the UserControl and a headline over.

solve the FileNotFoundException for the iTextSharp.dll on Windows Server 2008 R2

In a previous post I wrote a little function to convert HTML to PDF. I wanted to use this function on a server and start it with an event. The silly thing was that nothing happened. Later I figured out that the program crashed. It threw a  FileNotFoundException with the statement "PublicToken = 8354ae6d2174ddca", but the DLL was there and the reference was correct too. Soooo I had to figure out why the error appeared.. It took a wohle day, but now I can present a solution. The architecture of a server stores assembleys in a Global Assembley Chache (GAC) to use them. So the server was looking for the assembley in the GAC and that is why the server was not able to find it. Right now the FileNotFoundException seems to be logic.

Add external tools to Visual Studio

Image
External tools in Visual Studio are great "Add-Ons". There are so many usefull tools, you just need to know them. For example you can create .NET classes out of XML-Shemas(XSD) or add DLLs to the Global Assembley Cache (GAC) of a server. To configure an external tool you need to call Visual Studio 2010 or above. Press "Tools" and go to "external Tools...". A mask appears.