SCSF – giving a smartpart a title using attributes

When creating a [SmartPart] in SCSF, and adding it in a Tabbed Workspace, its title is empty by default. This results in a tab without a label in the workspace, not a pretty view.
The standard way to solve this is to implement the ISmartPartInfoProvider interface and then add code like this:
 

#region

ISmartPartInfoProvider Members

public ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)

{

    return new SmartPartInfo("Dashboard", "Your dashboard");

}

#endregion
 

I agree that this isn’t very much trouble, but here is the smarter solution:

I added a new class into the Infrastructure project:

public

class SCSFUserControl : UserControl, ISmartPartInfoProvider

{

  #region

ISmartPartInfoProvider Members

  public virtual ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType)

  {

    Type me = GetType();

    SmartPartInfoProviderAttribute[] atts = (SmartPartInfoProviderAttribute[])me.GetCustomAttributes(typeof(SmartPartInfoProviderAttribute), true);

    if (atts.Length == 0)

    {

      return new SmartPartInfo();

    }

    return new SmartPartInfo(atts[0].Title, atts[0].Description);

  }

  #endregion

}
 

Now we have to define the SmartPartInfoProviderAttribute:

[

AttributeUsage(AttributeTargets.Class)]

public class SmartPartInfoProviderAttribute : Attribute

{

  public string Title;

  public string Description;

  public SmartPartInfoProviderAttribute() : this(string.Empty, string.Empty)

  { }

  public SmartPartInfoProviderAttribute(string title, string description)

  {
    Title = title;
    Description = description;
  }
}
 

Creating a new smartpart now becomes easy:

[

SmartPartInfoProvider("Tasks", "Task list")]

public partial class TasklistView : SCSFUserControl, ITasklistView

// Your code here

 

And it will have a label in the Tabbed Workspace.

Posted in Development | Leave a comment

Choose Items crashing Visual Studio 2008

When trying to choose items to add to the toolbox in VS 2008 the following happened:
* Wait for a couple of minutes
* VS 2008 shuts down, no error message, just gone.
 

After the crash, the following events appears on the event viewer:

* .NET Runtime version 2.0.50727.3031 – Fatal Execution Engine Error (70E58C4E) (0) – Event Id: 1023
* .NET Runtime version 2.0.50727.3031 – Fatal Execution Engine Error (70BAF16D) (80131506) – Event Id: 1023

 
  1. devenv /setup
  2. devenv /resetuserdata
  3. devenv /resetsettings CSharp
but it doesn’t seem to change a thing Teleurgesteld
Then I removed all my add-ins (one 😉 and tried again. Same result.
 
According to some blogs this would be due to the installation if Powercommands for VS 2008 (Power commands: http://code.msdn.microsoft.com/PowerCommands/Release/ProjectReleases.aspx?ReleaseId=559). It is recommended to uninstall these and then install them again. I haven’t installed them, but I’ll try that now, hoping that it works.
Another post on this: http://social.msdn.microsoft.com/forums/en-US/vssetup/thread/e2434065-9921-4861-b914-9cc9d6c55553. Problem: they keep on referring to Powercommands, which I haven’t installed.
 
Finally the solution was quite simple:
 
devenv /safemode
Then use Choose Items on toolbox and run through each of the tabs. Once you
accept any exceptions raised on loading controls, you can then open Visual
Studio normally and add items.
 
 
 
Posted in Development | Leave a comment

How to close the current SmartPart in a CAB application

I have this SCSF (CAB) application in which I want to close the current tab (TabbedWorkspace) programmatically when the user closes it. So I took these steps:
 
1. In the Shellform add a context menu with one element: "Close"
2. Then add a menu handler :

private void closeToolStripMenuItem1_Click(object sender, EventArgs e)

{

    object obj = _leftWorkspace.ActiveSmartPart;

    _leftWorkspace.Close(obj);

}

Now users can close any smartpart by right clicking the tab page and selecting Close. It is easy to add other functionality to the context menu now, like "Close All but This".

Posted in Computers and Internet | Leave a comment

Font ‘Arial’ does not support style ‘Regular’

I had this error regularly in Visual Studio (2005) when I tried to add some controls to a form. And then I started having it in other applications as well so I started to look around what it could be.
It had to do with the Arial font (dôh); so I decided to re-install all the Arial fonts on my machine. This can be done by going into the %windows%\Fonts folder and copying all the arial¨.ttf files into a temporary folder. Then just double click them and it will re-install the font for you. This seems to have solved my problem
 
For backup information on this check this page out:
Posted in Geen categorie | Leave a comment

WCF – get identity of calling user

To get the identity of the calling user of your web method, you can use something like this:
 
string name = OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name;
 
Constraint: your service contract must have a session. In WSSF you can change this in the Service Contract Model on the ServiceContract element.
Don’t forget on the endpoint (Host Explorer) to add an enpoint with a wsHttpBinding Binding Type.
Posted in Development | Leave a comment

Debugging a webservice created by WSSF

To debug the webservice rightclick on the solution name and get the Startup Projects. Select the client app that you’re going to use for your debugging, and put its action on start or start without debugging.
Do the same for your webservice project.
When you hit F5 now, you’ll be able to debug in the client and in your webservice.
Posted in Development | Leave a comment

WSSF

Today I’ve been investigating the Web Service Software Factory: Modeling Edition.
I have gone over the tutorial and created my first web service with it. It’s a great tool to model your web services first, and then implement them. The possible models are a Service Contract Model, Data Contract Model and Host Model; each with their own purpose.
 
I have created my first real service with it and ran in this (little) problem:
I have given my solution a name (say Service1), and then when I wanted to implement my service I wanted to give the service project the same name. This doesn’t work. Lesson learned: give your solution a generic enough name.
 
More on this later.
Posted in Development | Leave a comment