The project Demo.clouds dosen't run as a library in a new form project.

Topics: General
Dec 17, 2010 at 1:25 PM


I explain my prblem.


Using the project Demo.clouds, I made some changes in it.   I'have removed the Form.

Then I created a custom control like MapaContro.cs to put the same code from the removed Form. So then I can use this project as a librarie in another project.

It compiles perfectly.

Then, when I create a new project to import the library, I can put the new control from the toolbox and shows the map on the form. However, when I execute it, visual studio show me the next error.

Could not load file or assembly 'CloudsDemo, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.


I have tested the references and all the libraries are included, I think.,,

Why it dosen't run as a custom control in a library.


I'm a little desesperated.


If you could help me.


Thank you very much.

Dec 17, 2010 at 1:56 PM

Sorry, it was my problem. I had put x86 instead of any CPU.


But now it shows the map. However, without any image with that message:

exception: The type initializer for 'SingletonCreator' threw an exception.

We are sorry, but we don't have imagery at this zoom level for this region.


This the code of the custom control:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;

using System.Text;
using System.Windows.Forms;
using GMap.NET;
using GMap.NET.WindowsForms;
using GMap.NET.Properties;

namespace CloudsDemo

    public partial class EatMapetaGoo : UserControl

        // clouds boundaries
        readonly PointLatLng gtl = new PointLatLng(50.4066263673011, -127.620375523875);
        readonly PointLatLng gbr = new PointLatLng(21.652538062803, -66.517937876818);
        readonly PointLatLng pointSector2 = new PointLatLng(37.96335, -7.54113);
        readonly PointLatLng pointSector1 = new PointLatLng(37.972264, -7.505593);
        readonly GMapOverlay mainOverlay;
        readonly GMapImage hidrat;
        readonly GMapImage sector;

        public EatMapetaGoo()


            if (!DesignMode)
                ////   System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("");
                //// }

                //bool ok = GMaps.Instance.ImportFromGMDB(@"C:\Users\eldruida\Desktop\nivellsSectors.gmdb");
                //if (ok)
                //    MessageBox.Show("Complete!", "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    MessageBox.Show("Failed!", "GMap.NET", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                    System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("");
                    //MapControl.Manager.Mode = AccessMode.CacheOnly;
                    MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET - CloudsDemo", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                mapControl1.OnMapZoomChanged += new MapZoomChanged(mapControl_OnMapZoomChanged);

                mainOverlay = new GMapOverlay(mapControl1, "top");

                hidrat = new GMapImage(gtl);
                hidrat.Image = Properties.Resources.bigMarkerGreen;
                sector = new GMapImage(pointSector1);
                sector.Image = Properties.Resources.sector1;




        void mapControl_OnMapZoomChanged()
            if (hidrat != null)
                var tl = mapControl1.FromLatLngToLocal(gtl);
                var br = mapControl1.FromLatLngToLocal(gbr);

                hidrat.Position = gtl;
                //clouds.Size = new System.Drawing.Size(br.X - tl.X, br.Y - tl.Y);
                hidrat.Size = new System.Drawing.Size(hidrat.Size.Width, hidrat.Size.Height);

            if (sector != null)
                var tl = mapControl1.FromLatLngToLocal(pointSector1);
                var br = mapControl1.FromLatLngToLocal(pointSector2);

                sector.Position = pointSector1;
                sector.Size = new System.Drawing.Size(br.X - tl.X, br.Y - tl.Y);


        protected override void OnLoad(EventArgs e)

            mapControl1.SetZoomToFitRect(RectLatLng.FromLTRB(gtl.Lng, gtl.Lat, gbr.Lng, gbr.Lat));


Dec 17, 2010 at 5:19 PM