Search code examples
c#webformswindows-server-2012eyeshot

ZoomFit error when using Eyeshot 2021 on Windows Server


Good afternoon, I am trying to use Eyeshot in a .NET Framework Web Application to create a Bitmap image. The steps of the process in my code are the following: I generate all the necessary Entities and then I add them to a Model control that is not visible in the Web Application; once all Entities are added, I use the ZoomFit() method to zoom to the desired Entities and then I use the RenderToBitmap() method to create the Bitmap image. The issue regards the ZoomFit() method: when executed, it gives the following error message: "Control's handle must be created first". The portion of code regarding the creation of the Model control is the following:

Model model1 = new Model();
model1.InitializeViewports();
model1.Size = new Size(500, 300);
model1.CreateControl();

model1.Layers.Add("Grid");
model1.Layers["Grid"].LineWeight = 0.3f;
model1.Layers["Grid"].Color = Color.LightGray;

model1.Layers.Add("Gauges");
model1.Layers["Gauges"].LineWeight = 1.5f;

// List of entities for correct zooming
IList<Entity> Grid = new List<Entity>();
IList<Entity> Gauges = new List<Entity>();

// List of strings containing the paths to the dxf files on the server
List<string> drawingsFilePaths = (List<string>)Session["drawingsFilePaths"];

// List of images
List<Bitmap> drawings = new List<Bitmap>();

foreach (string path in drawingsFilePaths)
{
// Clearing the entities every time I change the file
model1.Entities.Clear();

// Creating the viewport starting from the dxf files
ReadAutodesk read = new ReadAutodesk(path);
read.DoWork();

foreach (Entity en in read.Entities)
{
if (en.LayerName == "Grid")
{
Grid.Add(en);
}
else if (en.LayerName == "Gauges")
{
Gauges.Add(en);
}
model1.Entities.Add(en);
}

model1.ActiveViewport.OriginSymbol.Visible = false;
model1.ActiveViewport.ViewCubeIcon.Visible = false;
model1.ActiveViewport.ToolBar.Visible = false;
model1.ActiveViewport.SetView(viewType.Right);
model1.ZoomFit(Gauges, false);
Bitmap tmp = model1.RenderToBitmap(1);
drawings.Add(tmp);

However, this issue is faced ONLY when publishing the Web Application on a remote Server (Windows Server 2012); in fact, when I publish it using my own personal computer (Windows 10) as a server, everything works perfectly. I already checked the presence of all the Eyeshot DLLs in the pubblished Web Application, and the settings of IIS on my PC and on the Server are the same. Could it be an issue related to some missing references that are implicitly called by Eyeshot DLLs and are not present on Windows Server? What do you think is the problem?

Kind regards,

Giacomo Balestrieri


Solution

  • This is a licensing issue. Eyeshot Trial version cannot be copied on other machines. The same problem would occur if you copy your app to a different Win10 machine.