IIS targetFramework not supported

31. January 2011 10:55 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

 

I had a situation where the IIS reported that the targetFramework=4.0 attribute
was not supported.

I’m not sure why it started reporting it, but I fixed it with this:

%windir%\Microsoft.NET\Framework\v4.0.21006\aspnet_regiis.exe -i

Restoring simple lookup capabilities to Silverlight ListBox

27. January 2011 04:09 by Mrojas in General  //  Tags: , , , , , , ,   //   Comments (0)

VB6 and WinForms ListBox has the built in capability to provide a simple data look up. But the Silverlight ListBox does not.
So if you have a list with items:

Apple 
Airplane 
Blueberry 
Bee 
Car 
Zoo 
Animal Planet

And your current item is Apple when you press A the next current item will be Airplane

Apple 
Airplane 
Blueberry 
Bee 
Car 
Zoo 
Animal Planet

And the next time you press A the next current item will be Animal Planet

Apple 
Airplane 
Blueberry 
Bee 
Car 
Zoo 
Animal Planet

And the next time you press A the next current item will be Apple again

Ok to do in Silverlight you need to add a event handler. You can create a user control and this event handler and replace your listbox for your custom listbox or just add this event handler for the listboxes that need it. The code you need is the following:

void listbox1_KeyDown(object sender, KeyEventArgs e)
{
    String selectedText = this.listbox1.SelectedItem.ToString();
    String keyAsString = e.Key.ToString();
    int maxItems = listbox1.Items.Count;
    if (!String.IsNullOrEmpty(selectedText) && 
        !String.IsNullOrEmpty(keyAsString) && keyAsString.Length == 1 && 
         maxItems > 1)
    {   
        
        int currentIndex = this.listbox1.SelectedIndex;
        int nextIndex    = (currentIndex + 1) % maxItems;
        while (currentIndex != nextIndex)
        {
            if (this.listbox1.Items[nextIndex].ToString().ToUpper().StartsWith(keyAsString))
            {
                this.listbox1.SelectedIndex = nextIndex;
                return;
            }   
            nextIndex    = (nextIndex + 1) % maxItems;   
        }
        //NOTE: theres is a slight different behaviour because for example in 
        //winforms if your only had an item that started with A and press A the selectionIndex
        //will not change but a SelectedIndexChanged event (equivalent to SelectionChanged in Silverlight)
        //and this is not the Silverlight behaviour
    }
    
}

ASP to ASP.Net Migration: Fixing Includes

24. January 2011 08:43 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

During a migration from ASP to ASP.NET one of the biggest hurdles is finding a way to deal with the include files.

ASP was a interpreted environment whether ASP.NET is compiled and this difference is very important because you need to find ways more natural in .NET to do some things you used to do in ASP.

For example in ASP you used to have a set of common functionality that was included in your files. What will you do with that?

For ASP ASP.NET in VB.NET is a lot easier. One of the things you can do is move all those common subs and functions to a Module.

Now if what you have is a ASP.NET Web Site, then just your new modules to the App_Code folder and voila your pages are now able to see that code.

For a ASP.NET Web Application is just a little differente. What you have to do is move your common variables, constants, subs and functions to a Module, but that is not enough to make that code reachable from your mark up, so you have two alternatives:

1. Add an %@import Namespace=”QualfiedNamespaces.Module1”  statement for each of your modules.

2. Modify your web.config file and add under system.web something like:

<system.web>
              <pages>
                     <namespaces>
                           <add namespace="WebApplication1.Module1"/>
                     </namespaces>
                     
              </pages>

That will add an implicit import for all your pages.

For C# it can be a little more complicated. Because you do not have modules like in VB.NET, what you can do is use extension methods, to have a similiar syntax.

Split Config files in several files

6. January 2011 10:25 by Mrojas in General, WCF  //  Tags: , ,   //   Comments (0)

In .NET Framework 2.0 the attribute configSource was added to several elements of the .NET config files so you could use external files.

Sadly those attribute are not available for the system.serviceModel.However I found this post that shows a interesting workaround.

You can modify your serviceModel file to look like this:

<configuration>
 
  <system.serviceModel>
    <services configSource="Services.config" >
    </services>
 
    <bindings configSource="Bindings.config">
    </bindings>
 
    <behaviors configSource="Behaviors.config">
    </behaviors>
 
  </system.serviceModel>
 
</configuration>

And then you can put your configuration settings in separate files like the following:

Behaviors.config

<configuration>
 
  <system.serviceModel>
    <services configSource="Services.config" >
    </services>
 
    <bindings configSource="Bindings.config">
    </bindings>
 
    <behaviors configSource="Behaviors.config">
    </behaviors>
 
  </system.serviceModel>
 
</configuration>

For more details see the full post by Pablo Cibraro

Upgrading Applications Written in Earlier versions of Visual Basic for example VB4, VB5

21. December 2010 05:01 by Mrojas in VB6 Migration  //  Tags: , , , , , , , , , ,   //   Comments (0)

Some time ago Artinsoft participated in the development of a book called “Upgrading Visual Basic 6.0 Applications”.

I quote from that book:

“The upgrade wizard is designed to upgrade Visual Basic 6.0 applications. For
projects written in Visual Basic versions 1.0 through 5.0, it is necessary that you first
upgrade them to Visual Basic 6.0 before upgrading to Visual Basic .NET. To upgrade
a project that was developed in a version earlier than Visual Basic 6.0, simply open
the project in the Visual Basic 6.0 IDE and save it. If Visual Basic 6.0 prompts you to
upgrade controls to Visual Basic 6.0, choose Yes. If the project contains Visual Basic
5.0 ActiveX controls, it is often best to replace these controls with Visual Basic 6.0
versions. This is because these controls use a different threading model than models
used by Visual Basic 6.0 controls. The earlier threading model is not supported in
Windows Forms.
For 16-bit projects written in Visual Basic versions 1.0 through 4.0, you may need to
make extra modifications to the application to convert it to Visual Basic 6.0.
VBX controls will not be automatically converted. You will also have to replace
Win16 Windows APIs with their Win32® counterparts.
Visual Basic versions 2.0 and 3.0 often require an extra step. Visual Basic 6.0 can only
open files in text format, whereas Visual Basic versions 2.0 and 3.0 support two file
formats: binary and text. Before upgrading these projects, ensure the entire applica-
tion is saved in text format by using the following procedure.

To convert Visual Basic 1.0 and 2.0 files to text format
1. On the File menu, click Save As.
2. In the Save dialog box, select the Save As Text check box.
Because Visual Basic 1.0 can only save files in binary format, all of these projects will
first need to be opened in Visual Basic 2.0 or 3.0 and then saved as text before they
can be converted to Visual Basic 6.0. After converting the project to Visual Basic 6.0,
you can begin the process of upgrading it to Visual Basic .NET.”

This book is available for free
from the MSDN

Could not load file or assembly ‘App_Web_ ….

16. December 2010 04:53 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)

If you ever get an error like, it is an annoying situation where the web server is trying to use and old compilation of your aspx files.

The workaround I have is: rename web.config to stopweb.config.

Browse to the offending page URL it will return an error. After you receive the error rename stopweb.config to web.config

Browse to the offending page. This will force the server to compile the web pages.

And if it work the problem will now go away.

Migrate JSP to ASP.NET MVC

14. December 2010 06:19 by Mrojas in General  //  Tags: , , , , ,   //   Comments (0)

ASP.NET has gone a long way. And it might be the right time to start moving your sites to ASP.NET.

But what happens if you have a big investment in JSP. Will I lose all my JSP skills?

Well ASP.NET is not the same as JSP but the MVC view engine concept can help you retain some of the JSP flavor.

A good MVC View Engine project is SharpTiles this project provides a partial implementation of JSTL and Tiles.

Just take a look at the the SharpTiles. Just as they say SharpTiles if for you if “You are a Java Developer and you don’t like .aspx”

Determine is executable is a console application

30. November 2010 03:36 by Mrojas in General  //  Tags: , ,   //   Comments (0)

 

I you were looking for a way to do that just take a look at this post: http://weblogs.asp.net/whaggard/archive/2004/08/30/223020.aspx

Just notice that for this post you need to add this struct:

[StructLayout(LayoutKind.Sequential)]
public struct SHFILEINFO
{
  public IntPtr hIcon;
  public IntPtr iIcon;
  public uint dwAttributes;
  [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
  public string szDisplayName;
  [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
  public string szTypeName;
};

Custom tool warning: Cannot import wsdl:portType

25. November 2010 05:04 by Mrojas in General  //  Tags: , , ,   //   Comments (0)

During a Silverlight migration project from VB6 I was trying to add a WCF reference,
everything seemed to work in the wizard but no code was generated.

After reviewing the Warning messages, i found that some said:

Custom tool warning: Cannot import wsdl:portType

What I did to solve this issue?

1. Right click on your service reference

2. Select Configure Service reference

3. Uncheck the option that says Reuse types in referenced assemblies.

image

4. Press OK

After that VS generated the code and I could use the WCF service.

Lightswitch Experiences: Migrating Access to Microsoft Lightswitch

25. November 2010 03:07 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)

 

 

Microsoft Access was (and is still) very used for simple data entry applications.
But Microsoft Access despite all its good is kind of an old technology and there was
no clear alternative for a simple mortal development environment… until Microsoft Lightswitch.

This series of posts illustrates the experiences of migrating Microsoft Access applications to LigthSwitch.

This post shows the result of migrating all Northwind Access example tables:

The following is Microsoft LightSwitch Solution explorer showing all Tables

image

 

And these are some of the Northwind tables in LIghtswitch

 

image

image

 

image

image

 

image

 

image

 

The migration process is straightforward. Text and Memo fields can be migrated to string, Numbers can be migrated to Int32 or Int64, Currency is map to Money. Yes\No can be mapped to boolean with a Value List.

There is support for specifying a caption (Display ID in Lightswitch), Description, and validation rules.

I will keep posting about Query migration, form migration and also  report migration. Stay tuned.