Reporting Services – ReportExcecution2005 – Credentials and URL property missing

Today I was a bit confused during render a report programmatically.
I followed the example by Microsoft: http://msdn.microsoft.com/en-us/library/
reportexecution2005.reportexecutionservice.render.aspx (click)

I added the service reference for report execution and consumed it by a proxy.
Finally I was wondering why my proxy did know about the Credentials and Url Property and some other missing stuff.

ReportExcecution2005_Credentials_and_URL_property_missing

 

Finally figured out my little configuration issue, I used the “Add WCF Service dialog” instead the old “Web Service dialog”. After switch and rebuild all was fine.

Posted in Reporting Services | Leave a comment

Word Abbildungsverzeichnis Punkte entfernen

Frage einer Freundin – wie entfernt man die Punkte zwischen Bildunterschrift und Seitenzahl im Abbildungsverzeichnis von Microsoft Word (2007)?

Da ich die Antwort selbst auch nicht direkt wusste, hier noch mal für euch alle wie man die Punkte im Abbildungsverzeichnis von Word mit Leerzeichen ersetzt:

1. Cursor irgendwo zwischen die Punkte stellen

2. Tabstopp auf Höhe der Seitenzahl doppelklicken

3. Füllzeichen auf Ohne stellen

Word_2007_Abbildungsverzeichnis_Punkte_entfernen_Stefan_Scheller

Hier das Ergebnis:

Word_2007_Abbildungsverzeichnis_Punkte_entfernen_punkte_weg_Stefan_Scheller

 

Alternativ kann auch das Abbildungsverzeichnis entfernt werden und ein neues eingefügt – hier kann im entsprechendem Formular auch das Füllzeichen eingestellt werden.

Posted in variouse code | Tagged , , | Leave a comment

CTRL + F3 find next location of selected text in Visual Studio

CTRL + F3 is awarded for  >VS shortcut of the week <

This handy shortcut helps to find the next location of the selected text without opening the search window.

Posted in variouse code | Tagged | Leave a comment

Could not load file or assembly ‘Microsoft.Xrm.Client at plugin registration

Could not load file or assembly ‘Microsoft.Xrm.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.

Got this exception during the deployment of a plugin using the xrm library. By questioning the internet I found a lot of sources talking about different versions of dll (32 vs 64 bits) like over here: Could not load file or assembly

Sounds possible but anyways in my case the solution was to add all the xrm dlls to the directory the plugin registration tool is executed.

could_not_load_file_or_assembly_Microsoft_Xrm_Client_stefan_scheller

Complete exception:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Xrm.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.Assembly._GetExportedTypes()
   at PluginRegistrationTool.AssemblyReader.RetrievePluginsFromAssembly(String path)
   at PluginRegistrationTool.AssemblyReader.RetrievePluginsFromAssembly(String path)
   at PluginRegistrationTool.RegistrationHelper.RetrievePluginsFromAssembly(String pathToAssembly)
   at PluginRegistrationTool.PluginRegistrationForm.btnLoadAssembly_Click(Object sender, EventArgs e)

Posted in Dynamics CRM | Tagged , | Leave a comment

Unable to load the connection string name

Today I was concerned by the “Unable to load the connection string name” exception.stefan_scheller_unable_to_load_connection_string

Simplified my setup looks like in the picture. I am running a ms unit test project with a service reference for the WCF service and the service references a class library to come a long with the business tasks.

Within the class library I use the ms crm xrm framework to get a typed layer of your crm business objects.

The xrm data context is build up like that:

var context = new Xrm.mynameDataContext("MyConnectionString");

By running the unit test I got all the time the exception “Unable to load the connection string myConnectionString”. I did add the connection string to my Class Library app.Config and my client app.config like that:

<configuration>
...
  <connectionStrings>
    <add name="MyConnectionString" connectionString="Authentication Type=AD; Server=http://myserver/myorganisation; User ID=mydomain\myaccount; Password=*****"/>
  </connectionStrings>
...
</configuration>

The DataContext tries to retrieve the connection string like this:

ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

So the ConnectionStrings Collection did never contain the connection string.

With a second look on the architecture finally I got the clue: The point is that my entry point on server side for the library execution is obviously not the  client.

solution is:

Add your connection string to your WCF Service web.config or app.config

The calling client does not need any connection strings, sometimes logical things let us stumble especially if we got many layers in real life projects.

Posted in Dynamics CRM, variouse code | Leave a comment

Frage mobil erfassen auf trainontrain.com/mobile

Die Community zur Brainperformancesteigerung hat ein cooles neues Feature bekommen. Ab heute kann man unterwegs auf der Handy optimierten Version der trainontrain Community einzelne Fragen schnell erfassen.

Damit bedienen wir das Szenario: Wir lernen etwas und wollen es direkt in unseren Wissensschatz übernehmen indem wir mit nur einem Klick das Formular zur Erfassung öffnen und das unterwegs. Schneller geht es kaum und uns entgeht nichts mehr.

Einfach mobil einloggen (http://trainontrain.com/mobile/home) und schon seht Ihr den neuen Link zur Fragenerfassung.

trainontrain_com_feature_frage_mobil_hinzufuegen

Oder direkt den Bookmark aufs Handy: http://trainontrain.com/mobile/QuickQuestion/Create

Die Erfassungsseite schaut dann so aus:

trainontrain_com_feature_frage_mobil_hinzufuegen_sammlung_waehlen

Wir wählen aus zu welcher Fragensammlung die neue Frage hinzugefügt wird. Denkt dran die Fragensammlung selbst werden über die website (www.trainontrain.com) angelegt.

Nachdem wir den “Create” Button gedrückt haben, landen wir wieder auf der Startseite und können weitere Fragen erfassen oder einen Test starten.

Viel Spass – das TrainOnTrain Team

Posted in trainontrain.com | Tagged , , , | Leave a comment

Best Practice – ASP.NET MVC transfer data between controller and view

During the last weeks I had the opportunity to dive into data binding with ASP.NET MVC these are my experiences.

One main task with ASP.NET MVC  is to transfer M-odel data in our V-iew by the C-ontroller. Important is that we distinguish between DOMAIN Model and VIEW Model. Within the most tutorials we do not have any difference between the two models, as the use cases are very straight forward, but as soon we do a real life application we have complex and related objects or just need to present more than one object in our view. When we face such kind of situation we have 2 solutions:

A) use the ViewData object as a loosely typed dictionary and pass all our objects as object type:

 

controller code:

public ActionResult IndexUntyped()
{
    Car car = new Car();
    car.Name = "Audi Q7 S line";
 
    Owner owner = new Owner();
    owner.Name = "Stefan";
 
    //add the model data
    ViewData["car"] = car;
    ViewData["owner"] = owner;
    
    return View();
}

 

view code:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>IndexUntyped</title>
</head>
<body>
    <div>
     The cars's name is <%
   1: : ((MvcApplication1.Models.Car)ViewData["car"]).Name 

%> <br />

     The owners's name is <%
   1: : ((MvcApplication1.Models.Owner)ViewData["owner"]).Name 

%>

    </div>
</body>
</html>

 

 

B) use the ViewData.Model Property and assign a special designed ViewModel

 

controller code:

public ActionResult IndexStrongtyped()
{
    Car car = new Car();
    car.Name = "Audi Q7 S line";
 
    Owner owner = new Owner();
    owner.Name = "Stefan";
 
    //the view model
    VM_CarOwners vm_CarOwners = new VM_CarOwners();
    vm_CarOwners.Car = car;
    vm_CarOwners.Owner = owner;
 
    ViewData.Model = vm_CarOwners;
 
    return View();
    //retrun View (vm_CarOwners); //works as well
}

view code:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<MvcApplication1.Models.ViewModels.VM_CarOwners>" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>IndexStrongtyped</title>
</head>
<body>
    <div>
    The cars's name is <%
   1: = Html.LabelFor(x => x.Car) 

%> <br />

    The owners's name is <%
   1: = Html.LabelFor(x => x.Owner) 

%>

    </div>
</body>
</html>

 

For the most use cases best practice is to create a special ViewModel which holds all the expected data and assign it the ViewData.Model property and use strong typed views with HTML Helper using LINQ. You gain compile time error detection, the possibility to use automatic refactor features of Visual Studio, intellisense support and last but not least much less issues when you retrieve the data back by a later post.

 

Simple architecture could look like this:

ASP_NET_MVC_ARCHITECTURE_BEST_PRACTICE

(the ViewModel is a simple class with only properties to exchange data between the Controller and View and back)

 

If your are in a scenario you need data globally in many views with different or no strong typed model, then it is time for the flexibility of the untyped View Data Dictionary, i.e. : <%: ViewData["currentPageNumber"] %>

 

 

If you are confused about the TempData vs ViewData  – TempData is for redirect model data to other methods.

There is a nice explanation over here: TempData Is Really RedirectData .

 

You can download the complete sample code here.

Posted in ASP.NET MVC2 | Leave a comment

CS0135: ‘Model’ conflicts with the declaration ‘System.Web.Mvc.ViewPage.Model’

When you build ASP.MVC Websites you can use HTML Helpers and use a LINQ expression with them to get a certain property of your model.

As it is not forbidden you can use what ever you like as LINQ variable, so I did fall in the trap to copy some code for my view:

 

<%= Html.TextAreaFor(Model => Model.MyViewModelPropertyA) %>
<%= Html.ValidationMessageFor(Model => Model.MyViewModelPropertyA)%>

 

The control alone compiles pretty well, the issue

CS0135: ‘Model’ conflicts with the declaration ‘System.Web.Mvc.ViewPage<TModel>.Model’

is rising up as soon as we try to add an other more complex HTML Helper, for my case a drop down list:

<%= Html.DropDownListFor(
                x => x.MyViewModelPropertyB, 
                Model.MyViewModelObjectListC, 
            new { @class = “yellowDropDown” } 
) %>

 

As you guess the one alone works also pretty well, but the 2 controls in one page create the conflict.

Solution use something else for your lambda expressions like <%=Html.TextAreaFor(x => x.MyViewModelPropertyA)%>

Posted in ASP.NET MVC2 | 2 Comments

Create insert script including data with SQL Server Management Studio

Just tried to create a deployment script of my local MS SQL data base including the data.

This feature is well known by MySQL or Oracle Clients. Actually I could not find the feature in MS SQL Server Management Studio – BUT – the feature exists in Visual Studio 2010 :

Just Create a Database Connection, step on your database and right click “publish to provider…”

Create_Script_with_data_by_ms_sql_studio_stefan_scheller

Then you follow a lot of  continue – ok – ok – continue and finally you get a script like this one:

Create_Script_with_data_by_script_sql_studio_stefan_scheller

Posted in variouse code | Leave a comment

Visual Studio shortcut of the month Ctrl m o

As I had a lot of refactoring the last days my favourite VS short cut for this month:

Ctrl + m + o

It collapses all outlining.
This short cut is extremely cool when you have to gain bird’s eye view on methods in a class.

If you find a particular interesting one just place the curser on it and press

Ctrl + m + m

It expands (or later collapse) this certain method.

Posted in variouse code | Leave a comment