IE8 No such interface

17. August 2012 10:45 by Mrojas in   //  Tags: , , , , , ,   //   Comments (0)

Well, there are several reasons why this error appears...

I had this annoying error for a few days so I decided to track it down. It seems that in my case this error was a bug in jQuery.

if (document.documentElement.contains) {
            Sizzle.contains = function (a, b) {
                    return a !== b && (a.contains ? a.contains(b) : true);
            };

        }

 

That code throws the exception in the a.contains(b) method call. So I tried to fix it for a while but I did not have a lot of time so I ended up patching it like:

 

if (document.documentElement.contains) {
            Sizzle.contains = function (a, b) {
                try {
                    return a !== b && (a.contains ? a.contains(b) : true);
                }
                catch (err) {
                     return false;
                }
            };

        }
 
In my case it works. I know is not the best solution but if you are struggling with this it might help

How to use Windows Phone 7 with Lync

16. August 2012 10:39 by Mrojas in   //  Tags: , , , , ,   //   Comments (0)

It seems ironic but it seems that it is a little more difficult to configure Windows Phone 7 and 7.5 to work with MS Lync that it is to configure an iPhone or an iPad.

 

Well after trying for a while without success, I found this page: http://leonmeijer.nl/archive/2012/01/25/153.aspx

The steps are (and i quote):

 

Steps:

 

I like Windows Phone, I just think their apps need to be more polished.

System.Configuration.ConfigurationErrorsException When running from Network Share

31. July 2012 11:29 by Mrojas in   //  Tags: , , , ,   //   Comments (0)

My friend roberto found this error and it seems to be a know .net framework error

http://connect.microsoft.com/VisualStudio/feedback/details/559615/starting-application-from-network-share-and-access-config-section-fails

If you run the application from a network share you will get an exception like:

System.Configuration.ConfigurationErrorsException: An error occurred creating the configu
ration section handler for overrideConfigurations: Request failed. (R:\Development\Junk\n
ewConsole\TestConsoleApp.exe.Config line 5) ---> System.Security.SecurityException: Reque
st failed.


So the know workarounds listed in that page are:


 

http://support.microsoft.com/kb/182569Adding a ZoneMap for he the server/domain name with the network share and give it the Value 0 (Zone 0 = My Computer) did it!There is no GUI dialog to to this (because per default, you cannot change the "My Computer" zone in the internet settings.=>a) Hack the registry to get GUI access to the "My Computer" zone in the Windows internet settings and add the domain with the network share to the "My Computer" zone.b) Directly hack the registry by adding the network share machine name as a key to the Domains key of the ZoneMap (HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\) and give it the DWORD value "file=0".


And the other workaround (which I prefer is):

var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                var junk = config.GetSection("overrides/applicationSettings");

Quick way to tell if you can write a file in C#

31. July 2012 11:03 by Mrojas in   //  Tags: ,   //   Comments (0)

So a quick way to determine if you can write a file, which can use even from the debugger is to use something like:

 

System.IO.Directory.GetAccessControl(@"<filename>").GetAccessRules(true,true,typeof(System.Security.Principal.SecurityIdentifier))
 
This will return a list of access rules and you can examine them.
For each rule Check the AccessControlType==AccessControlType.Allow and not AccessControlType.Deny

Insert into select * for huge columns lists

19. July 2012 20:26 by Mrojas in   //  Tags: , , ,   //   Comments (0)

It is very easy to insert rows from one table to the other using an insert into and select * statement but to use this statement you need sometimes to provide the columns list and that is boring :(

So I quick way to do that is use a T-SQL snipped like this:

DECLARE @columns varchar(max)

SELECT @columns = Coalesce(@columns + ', ', '') +  column_name
FROM   information_schema.columns
WHERE  table_schema = 'dbo'
AND    table_name = 'Account'
ORDER
    BY ordinal_position

PRINT @columns

Speed up changes in Azure Web Roles

4. June 2012 00:37 by Mrojas in   //  Tags: , , , , , , , ,   //   Comments (0)

A common question I get for people that has just moved to Windows Azure Web Roles, is:

 

I just want to make a little change to a page but publishing takes too long, what can i do?

 

Well, there are several things you can do. Usually what I find is that their publishing takes too long because they need to upload a lot of data.. but why? The database is in Azure, so you don't have to upload it, and a asp.net web site is usually just some binaries and some text files?

 

For answering this question I love to use a tool called HDgraph (http://www.hdgraph.com/)

 

 

This tool provides a graphical representation of your hard drive allowing you easily identify which folders are the ones consuming most space.

 

What I usually find is a lot of graphics (jpg, png, gif files), videos (flv, avi), presentations (.pptx) and PDFs files, that are part of the site. No wonder why uploading site changes takes so long.

 

if you do that you are not really taking advantage of all the Azure platform features.

Azure provides a massive storage mechanism and you should take advantage of it.

 

But how do I do that?

 

First Download a tool like Azure Storage Explorer: http://azurestorageexplorer.codeplex.com/

 

 

Create a folder (well well a container)  for example content in Azure and upload your files to that container.

 

And now is time to set your CNAME record to point to your storage. Normally it will be something like making A CNAME content or media point to mycutesite.blob.core.windows.net.

(If you don't remember what a CNAME is lets say is something you configure with your registrar, the people you pay for your domain, so you can make entries to say for example if the browser navigates to www.mycutesite.com then send those requests to mycutesite.cloudapp.net and if they type media.mycutesite.com they it will redirect them to mycutesite.blob.core.windows.net)

 

 

I recommend reading Brandon Werner's excellent for very details quick intro to Windows Azure, from where I took this CNAME entries image.

 http://blogs.msdn.com/b/brandonwerner/archive/2009/11/28/how-to-host-your-site-and-content-on-azure-quickly-and-easily.aspx

 

 

 

Again the idea is that you will remove most of the content of your asp.net solution and change your html so all resources will be downloaded from media.mycutesite.com\content

 

And finally, take advantage of Windows Azure new WebDeploy feature which allows a fast way to modify your pages directly. See (http://blogs.msdn.com/b/cloud/archive/2011/04/19/enabling-web-deploy-for-windows-azure-web-roles-with-visual-studio.aspx)

 

Binding problem when Sending JSON object to MVC3

25. May 2012 16:59 by Mrojas in   //  Tags: , , ,   //   Comments (0)

After a frustrating couple of hours trying to determine WHY WHY my object did not bind with MVC3 I finally found why.

The story began like this.

I have a very simple method in a controller. Something like this:

 

public class Form1Controller : Controller
    {
        //
        // GET: /Form1/

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult DoButton1(Person zzz)
        { 
            System.Diagnostics.Debug.WriteLine(zzz.Name);
            return Json(data: "Good Test");
        }
   
       

    }
 
And I called that code with a jquery Statement like:
var person= JSON.stringify({ Name: "Mauricio", LastName: "Rojas" });              $.ajax({                                    
                    url: "/Form1/DoButton1/",
                    type: "POST",
                    dataType: "json",
                    data: person,
                    success: function () {
                        alert("OK");
                    },
   
                });
 
But!!! (maybe you already saw the obvious mistake) no matter what I sent, the Person object was not bind.
The action method got called but I was not able to see the sent values. I used Chrome developer tools and the network that show the
values I had modified.
SO WHYYYYY!!!!
I tried to debug the MVC code, but VS studio could not load the pdb, something I get that I still not sure why.
So how could I intercept what was happening? Simple with a ModelBinder.
A ModelBinder is class that is used to bind your request to a model object.
So I went to the Global.asax file and register my binder, and set some breakpoints.
//Code in Global.asax to register a Person Binder
    protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            ModelBinders.Binders.Add(typeof(Person), new PersonBinder());
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }

    public class PersonBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var contentType = controllerContext.HttpContext.Request.ContentType;
            if (!contentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                return (null);

            string bodyText;

            using (var stream = controllerContext.HttpContext.Request.InputStream)
            {
                stream.Seek(0, SeekOrigin.Begin);
                using (var reader = new StreamReader(stream))
                    bodyText = reader.ReadToEnd();
            }

            if (string.IsNullOrEmpty(bodyText)) return (null);

            var xx = new JavaScriptSerializer().Deserialize<Person>(bodyText);

            return xx;
        }
    }
 
And voila!! the content type I was getting was something like:application/x-www-form-urlencoded
 
So I just added the content type parameter to my javascript code:
$.ajax({                                    
                    url: "/Form1/DoButton1/",
                    type: "POST",
                    dataType: "json",
                    data: viewModelStr,
                    success: function () {
                        alert("inside");
                    }//,
                    contentType: 'application/json; charset=utf-8' 
                });
 

Binding problem when Sending JSON object to MVC3

25. May 2012 16:59 by Mrojas in   //  Tags: , , ,   //   Comments (0)

After a frustrating couple of hours trying to determine WHY WHY my object did not bind with MVC3 I finally found why.

The story began like this.

I have a very simple method in a controller. Something like this:

 

public class Form1Controller : Controller
    {
        //
        // GET: /Form1/

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult DoButton1(Person zzz)
        { 
            System.Diagnostics.Debug.WriteLine(zzz.Name);
            return Json(data: "Good Test");
        }
   
       

    }
 
And I called that code with a jquery Statement like:
var person= JSON.stringify({ Name: "Mauricio", LastName: "Rojas" });              $.ajax({                                    
                    url: "/Form1/DoButton1/",
                    type: "POST",
                    dataType: "json",
                    data: person,
                    success: function () {
                        alert("OK");
                    },
   
                });
 
But!!! (maybe you already saw the obvious mistake) no matter what I sent, the Person object was not bind.
The action method got called but I was not able to see the sent values. I used Chrome developer tools and the network that show the
values I had modified.
SO WHYYYYY!!!!
I tried to debug the MVC code, but VS studio could not load the pdb, something I get that I still not sure why.
So how could I intercept what was happening? Simple with a ModelBinder.
A ModelBinder is class that is used to bind your request to a model object.
So I went to the Global.asax file and register my binder, and set some breakpoints.
//Code in Global.asax to register a Person Binder
    protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            ModelBinders.Binders.Add(typeof(Person), new PersonBinder());
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }

    public class PersonBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var contentType = controllerContext.HttpContext.Request.ContentType;
            if (!contentType.StartsWith("application/json", StringComparison.OrdinalIgnoreCase))
                return (null);

            string bodyText;

            using (var stream = controllerContext.HttpContext.Request.InputStream)
            {
                stream.Seek(0, SeekOrigin.Begin);
                using (var reader = new StreamReader(stream))
                    bodyText = reader.ReadToEnd();
            }

            if (string.IsNullOrEmpty(bodyText)) return (null);

            var xx = new JavaScriptSerializer().Deserialize<Person>(bodyText);

            return xx;
        }
    }
 
And voila!! the content type I was getting was something like:application/x-www-form-urlencoded
 
So I just added the content type parameter to my javascript code:
$.ajax({                                    
                    url: "/Form1/DoButton1/",
                    type: "POST",
                    dataType: "json",
                    data: viewModelStr,
                    success: function () {
                        alert("inside");
                    }//,
                    contentType: 'application/json; charset=utf-8' 
                });
 

Output unescaped string in Razor

24. May 2012 00:03 by Mrojas in   //  Tags: , , , , ,   //   Comments (0)


 
While doing some experiments with Razor, and trying to generate some simple JSON objects in my ASP.NET MVC views
I had to deal with problems because my json string got a lot of weird &quot; and other strange escape character.
That in general is very good but I needed my string just as is.

The current workaround that I have found for doing that is:
 
var objectInStr = @(new HtmlString(Json.Encode(Model or your object)));
 
 

See SQL Server Express from other computers

23. May 2012 23:46 by Mrojas in   //  Tags: , , , , , , ,   //   Comments (0)

When I use SQLServer 2008 Express for my development tests, I always forget which things I have to do in order to make my SQL Server 2008 Express instance available to other machines over the networks.

So to not forget that again this are the things that you have to check to be able to acces sql server express from other machines:

 1. Go to the Start Menu\All Programs\Microsoft SQL Server 2008 R2\ and run SQL Server Configuration Manager

 

2. In the SQL Server Configuration Manager Window, expand the tree on the left and expand the SQL Server Network configuration element on the tree. Make sure that at least TCP/IP protocol is enabled. 

 

 

 

 

3. Now Click on the SQL Server Services element on the tree and make sure that the SQL Server Browser service is running. It is needed in order to make other computer able to see your server.

Problem using ActiveX controls with VS2010

11. May 2012 11:56 by Mrojas in   //  Tags: , , , , , , , ,   //   Comments (0)

 

Sometimes during migrations from VB6 to VS2010 we have found issues when you tried to add an ActiveX control with the VS2010 winforms designer. The issue is only present in VS2010 not on previous versions.

You usually will see an error in the added Interop references, and messages like a missing VBA or StdLib library.

The error has been reported several times so please vote on Connect to make sure MS will consider fixing it.

 

https://connect.microsoft.com/VisualStudio/feedback/details/557722/errors-utilizing-activex-controls-in-vs-2010

http://connect.microsoft.com/VisualStudio/feedback/details/568769/aximp-error-with-vb6-activex-control

 

And possible workarounds are running the Aximp manually from the command line and the add the references. You will then need to add the control by hand in your forms. Do not use the designer to add the component, this will try to regenerate the references and reproduice the issue.

The obscure way to open an Access 97 database with MDW Security in Access2010

10. May 2012 12:38 by Mrojas in   //  Tags: , , , , ,   //   Comments (0)

I was in an AccessMigration to SQL Server and i needed to open an Access97 database with security (using a system.mdw file).

It took me a while to do, but it is possible to open an Access97 Database in Access2010.

I really thing that it is a little obscure. But these are the steps:

1. First open Access2010

2. After Opening Access2010, press Ctrl + G. That will open the Microsoft Visual Basic for Applications window.

3. On the Immediate Window run this command (to run it just time the command and press Enter): DoCmd.RunCommand acCmdWorkgroupAdministrator

4. Once you run this command you will see a dialog with a title of Workgroup Administrator, press the Join Button

  

5. When you press the join Button a Dialog with Title Workgroup Information File will prompt Click Browse and find your System.mdw file and press OK. And press Ok on the Workgroup Administrator Dialog

6. Now close Access 2010

7. Open Windows explorer. Find your .mdb file and double click it. Access2010 will prompt for user/password and then will upgrade your database.

Getting ready for your certification tests

3. May 2012 10:58 by Mrojas in   //  Tags:   //   Comments (0)

Technology changes every day, and I consider that is part of my obligations as an Engineer to stay aware of the latest trends.

Some companies even demand that you should have certifications to backup your experience. Is not the same to say that you know WCF, as showing that have a certification my MS indicating that you at least know all the basics of WCF.

I have done some certifications in the past for MS and Sun (well now Oracle Java), and I want I have done is usually to research for documentation online or buy some books on the subjects of the certification exam. I have even bought guide books that prepare you for a certification test.

Recently the people from uCertify approached me and they let me evaluate one of their Certification PrepKits (at least that’s the way they call them).

Well this are my observations on the product.

The uCertifiy PrepKit is small application that you have to download to your computer. Once there is provides a personalized browser to an information portal.

You have to provide your email and license to be able to access your PrepKit. Once you do you will be presented with a page showing your current progress.

 

I think that must annoying thing about certification test is not knowing if you are ready or not (you do not want to pay for the test and do not pass it)

And the PrepKit is great for that. It provides a set of tests you can apply to yourself to verify your knowledge.

For example if you already know about the subject and what to know if you can pass a the test, give it a try to the diagnostic test:

 

 

All test in the prepkit provide some level of customization. So you can decide to take a quick 20 minute test of a longer 45 minute test.
Test mode is nice because sometimes you can feel very confident about a subject but during the test you miss some questions, so the test mode will leave you see which were the right answers.

I think is nice to start with the Diagnostic Test and then review a little about the subject. The prepkit provides study material. Just go to Notes\Study Notes and you will have access with several pages with information about the certification. This is very nice, because usually I have to look for a good page that provides information that I can use for a test. Certification test questions are very tricky they will ask about attribute combinations and configurations that you might not use very much so this notes can be a great help.

There are 4 predefined tests A, B, C and D and you can create your own test.

The best feature for me, is the ability to track your current progress.

 

Using the tests differs from buying a book or just using a web site, because they are more interactive.

 

You can write down your notes, you can make links to your info, and easily review your errors.

Conclusions

I had never used one of this PrepKits before, but they are a great experience. They are not cheap but I think they worth their price. Some years before I would have thought that I could just take my time and look for my own material on the web for my certifications, but now I’m a very busy professional, father and dog owner, so time is important for me, and keeping ahead in my career too. Thinks I would improve: better navigation, and little overhaul of the interface.

Customizing the Look and Feel or your Windows Forms Applications

27. April 2012 17:05 by Mrojas in   //  Tags: , , , , , ,   //   Comments (0)

Windows forms is still a great technology, but by default is not as flexible as XAML or HTML where you can very easily modify the style of your controls.

But that is not entirely true.

Let's review which options do we have for customizing the look and feel of Windows Forms Applications.

 

Custom Look And Feel

Well the idea is simple. Centralize all the settings for your components and make sure to invoke that logic just after the initializeComponent() method call on the Windows Form constructor.

I will implement a very simple example:

First the class the implements the "theming logic":

using System.Windows.Forms;
using System.Drawing;
public class ApplicationLookAndFeel
{
	static void ApplyTheme(TextBox c)
	{
		c.Font = new Font("Arial",12.0f); c.BackColor=Color.Blue; c.ForeColor = Color.White;
	}
	static void ApplyTheme(Label c)
	{
		c.Font = new Font("Arial", 12.0f); c.BackColor = Color.Black; c.ForeColor = Color.White;
	}
	static void ApplyTheme(Form c)
	{
		c.Font = new Font("Arial", 12.0f); c.BackColor = Color.Black; c.ForeColor = Color.White; 
	}
	
	public static void UseTheme(Form form)
	{
		ApplyTheme(form);
		foreach (var c in form.Controls)
		{
			switch(c.GetType().ToString())
			{
				case "System.Windows.Forms.TextBox":
					ApplyTheme((TextBox)c);
					break;
				case "System.Windows.Forms.Label":
					ApplyTheme((Label)c);
					break;


			}
		}
	}
}
As you see is just very simple code that will just update the settings for all controls, and a simple call in all form constructors and your done:
public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
			ApplicationLookAndFeel.UseTheme(this);
		}
	}
A form like:
 

 

This approach is simple, but could require a lot of work if you have a lot of components, and switching to another look and feel will require a lot of changes, and it does not allow you to customize all of the form.

Customization of non client are (title bar, borders, requires a little more work). You can take a look at Szymon Kobalczyk work in codeplex. There is a lot of information about a setting custom borders for your forms and even a start of a form styling library. 

 

Styling Controls

There are some third-parties that provide some level of Theming/Styling. The main difference is the impact they have on existing applications. I categorize them a Little Changes/Big Changes

 

Little Changes

Visual Styler.NET from http://www.skin-soft.co.uk/

This is an interesting solution, because it allows you to style your Standard Windows Form controls, with very little changes. You just add a control on you main form and that all.  They provide some custom styles and you can built your own. They support styling of ThirdParty Controls but I am not sure how that will work.

 

 

For screen shots and details see: http://www.skin-soft.co.uk/Products/VisualStyler/Overview.aspx

 

More Changes

Telerik Visual Style Builder http://www.telerik.com/products/winforms/visual-style-builder.aspx

 

 

 

DevExpress WinForms Skins http://www.devexpress.com/Products/NET/Controls/WinForms/Skins/

 

 

Infragistics Application Styling http://www.infragistics.com/resources/application-styling.aspx#ApplicationStyling

 

 

I call this "more changes" because all of them are great styling components but in order to style your application you have to use THEIR components. That is change all your TextBox for RadTextBox in the case of Telerik, Button for RadButton, or change your Label for WinLabel and your Button for WinButton for Infragistics and TextEdit for DevExpress...

So it can be a lot of changes. The end result can be stunning, because all of these companies have very very good components, but it is a lot of changes and can affect your application.

 

 But as you can see, Windows Forms still has a lot to offer

Share Code between Silverlight, Winforms and even Metro: Portable Library Tools

26. April 2012 09:33 by Mrojas in   //  Tags: , , , , , , , ,   //   Comments (0)

Maybe you faced the situation where you had code that was to be used on your server side services and also on your silverlight clients. 
Having this situation required some tricks because Silverlight Class libraries could not be used on .NET projects and viceversa.
Common workarounds were to share files and use precompilation directive iack!!

Well VS 2011 has a concept called Portable Class Libraries which allow you to create class libraries that can be use in Windows Phone, Silverlight, .NET framework, etc.

And if you have VS 2010 you don't have to suffer. Just use the Portable Library Tools from from the VS Extensions and start sharing code (see this image form the VS Extensions site)

  

 

For more details about Portable Libraries check the MSDN documentation page: http://msdn.microsoft.com/en-us/library/gg597391.aspx

 

Change Apache Default Port

25. April 2012 15:12 by Mrojas in   //  Tags: , , ,   //   Comments (0)

I was playing around with XAMPP trying out the OrangeHR open source application.

I installed XAMPP on a machine with an IIS 7 pointing to HTTP port 80. So when I tried to start apache, I encounter a conflict.

Modifying the Apache included with XAMPP to use another port is very easy. Go to the installation directory.

It usually is c:\xampp\

In c:\xampp\apache\conf look for file httpd.conf

Look for a line that says: Listen 80  and change it for the port you need. In my case Listen 78

Save the file. And restart apache and TA DA!!!

Customizing ToolStrip Items

2. April 2012 13:53 by Mrojas in   //  Tags: , , , , ,   //   Comments (0)

There are many types of ToolStrip<Control> classes.

But how can you create your own customized version. Let’s say you want a control that prefixes a label before your combo box?
Ok that is very simple, you just extend the ToolStripControlHost class

 

First we create our UserControl:
using System.Windows.Forms;

	public partial class ComboBoxWithLabel : UserControl
	{
		public ComboBoxWithLabel()
		{
			InitializeComponent();
		}

		public string LabelText
		{
			get {return label1.Text;}
			set {label1.Text = value;}
		}

		public ComboBox.ObjectCollection Items
		{
			get
			{
				return comboBox1.Items;
			}
		}
	}

	partial class ComboBoxWithLabel
	{
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		#region Component Designer generated code

		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.comboBox1 = new System.Windows.Forms.ComboBox();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Dock = System.Windows.Forms.DockStyle.Left;
			this.label1.Location = new System.Drawing.Point(0, 0);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(35, 13);
			this.label1.TabIndex = 0;
			this.label1.Text = "label1";
			// 
			// comboBox1
			// 
			this.comboBox1.Dock = System.Windows.Forms.DockStyle.Right;
			this.comboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.comboBox1.FormattingEnabled = true;
			this.comboBox1.Location = new System.Drawing.Point(35, 0);
			this.comboBox1.Name = "comboBox1";
			this.comboBox1.Size = new System.Drawing.Size(134, 21);
			this.comboBox1.TabIndex = 1;
			// 
			// ComboBoxWithLabel
			// 
			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.label1);
			this.Name = "ComboBoxWithLabel";
			this.Size = new System.Drawing.Size(169, 22);
			this.ResumeLayout(false);
			this.PerformLayout();

		}

		#endregion

		public System.Windows.Forms.Label label1;
		public System.Windows.Forms.ComboBox comboBox1;
	}
Next we just create an extension of the ToolStripControlHost
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms.Design;
using System.Windows.Forms;
using System.Drawing.Design;

[DefaultProperty("Items")]
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.All)]
public class MyCustomComboBoxWithLabel : ToolStripControlHost
{
	public MyCustomComboBoxWithLabel()
		: base(new ComboBoxWithLabel())
	{
	}
	[Browsable(false)]
	public ComboBoxWithLabel ComboBoxWithLabel
	{
		get { return base.Control as ComboBoxWithLabel; }
	}
	

	[Browsable(true)]
	[DefaultValue(false)]
	public string LabelText
	{
		get { return ComboBoxWithLabel.LabelText; }
		set { ComboBoxWithLabel.LabelText = value; }
	}

	[Localizable(true)]
	[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
	[Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor))]
	public System.Windows.Forms.ComboBox.ObjectCollection Items
	{
		get { return ComboBoxWithLabel.comboBox1.Items; }
		set {
			foreach (var item in value)
			{
				ComboBoxWithLabel.comboBox1.Items.Add(item);
			}
		}
	}
}
 
And Next ...
Well there is not next. You just used it :) And this is how it looks:

Migrating .NET applications to Windows CE

22. March 2012 12:05 by Mrojas in   //  Tags: , , , ,   //   Comments (0)

If you have a .NET application and then find that you need to move your application or
part of it to a Handheld or mobile device based in Windows CE don't worry.

The .NET has what is called the .NET Compact Framework which is in general
.NET for mobile devices. However review some info before you start your development
because it is not necessary the same. 

 

Differences between .NET Framework and Compact Framework

The CF is great but... it is not the .NET Framework. There

are differences take a look at: http://msdn.microsoft.com/en-us/library/2weec7k5.aspx

 

Controls

For a list of .NET Compact Framework Controls

See: http://en.wikipedia.org/wiki/.NET_Compact_Framework_controls

 

Some nice Third Party .NET Framework Controls are:

  • http://beemobile4.net/products/ipack/controls
  • http://www.resco.net/developer/mobileformstoolkit/overview.aspx

Some useful links:

Need remoting in .NET well you should know that CF does not provide Remoting but there

is company that implements it:

http://gotcf.net/

 

You can also use DCOM

http://www.codeproject.com/Articles/13819/Bringing-DCOM-remoting-functionality-to-Windows-CE

 

And for BlueTooth

There are several aproaches for developing BlueTooth with .NET.

1)  Bluetooth programming with Windows Sockers. 

See: http://msdn2.microsoft.com/en-us/library/aa362928(VS.85).aspx

2)   Windows Embedded Source Tools for Bluetooth.  

See: http://www.microsoft.com/windowsembedded/en-us/develop/windows-embedded-ce-6-bluetooth-technology-source-tools.aspx

3)    3rd party solution, A nice library is:

See: http://inthehand.com/content/32feet.aspx

Windows Services in CE

See this post: http://bansky.net/blog/2008/04/services-for-windows-mobile-in-managed-code/ 

and the library is available here:

http://managedserviceswm.codeplex.com/



 

Sending Messages between EXE files

13. March 2012 10:37 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)

Today someone asked what is a way to send messages between two .NET exes.

mmm Well. Interesting question. There are several approaches.

 

1. .NET Remoting

.NET remoting is not a new technology but is a core part of the

.NET framework and it's always available:

 

For an example see this code from: http://www.codeproject.com/Articles/62813/NET-Remoting-Events-Explained

 

2. Named Pipes

This is vb.net example: http://support.microsoft.com/kb/871044

 

3. WCF

WCF is a great option even if you have legacy VB6 code you can use the SOAP Client to communicate

with the service:

This link http://www.aspfree.com/c/a/VB.NET/Calling-a-Web-Service-using-VB6-with-SOAP-30/

shows an example calling a Coldfusion Service but use it as a base for calling 

a WCF service

You can also integrate WCF with COM+ http://msdn.microsoft.com/en-us/library/bb735856.aspx

 

4. Windows Messages

There is a nice project that wrap it all up for you so you can use this solution:

http://www.codeproject.com/Articles/17606/NET-Interprocess-Communication

 

 

Cannot uninstall Silverlight 4 and you want to install Silverlight 5

5. March 2012 14:50 by Mrojas in   //  Tags: , , , , , ,   //   Comments (0)

I faced this problem recently. I tried and tried but I got different error messages for uninstall Silverlight 4 SDK and I needed to upgrade to Silverlight 5.

So after a lot of tears and suffering I came across the Microsoft Fix it.

http://support.microsoft.com/mats/Program_Install_and_Uninstall

 

I runned this program and indicated that I wanted to uninstall Microsoft Silverlight 4 SDK and it was like magic!

It checked the registry, and fixed it, and then uninstalled the MS Silvelight 4 SDK.

After that I just download the new installer run it and everything work! Isn’t it something J

Categories