0
I have a winForm that I am passing to Webform, I created my Webform and I was passing the items slowly first put some buttons to see if it would work, I added the references, but one of them is giving problem, it seems that he does not find, will someone give me a light on how to solve this?
Winform
Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Flir.Atlas.Image;
using Flir.Atlas.Live.Device;
using Flir.Atlas.Live.Discovery;
namespace DualCamera
{
public partial class MainWindow : Form
{
private Camera _cam1;
private Timer _updateGuiTimer;
private bool IsSrc1Dirty { get; set; }
public MainWindow()
{
InitializeComponent();
Text = "ID Reitz - Câmera version: " + ImageBase.Version;
// set default directory where to save the snapshots.
textBoxImageLocation.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
// Create timer to update our UI.
_updateGuiTimer = new Timer {Interval = 30};
_updateGuiTimer.Tick += _updateGuiTimer_Tick;
_updateGuiTimer.Start();
}
void MainWindow_Src1Changed(object sender, Flir.Atlas.Image.ImageChangedEventArgs e)
{
IsSrc1Dirty = true;
}
void _updateGuiTimer_Tick(object sender, EventArgs e)
{
if (IsSrc1Dirty && _cam1 != null)
{
// a refresh is needed of source 1
try
{
// always lock image data to prevent accessing of the image from other threads.
_cam1.GetImage().EnterLock();
pictureBoxSource1.Image = _cam1.GetImage().Image;
}
catch (Exception)
{
}
finally
{
// We are done with the image data object, release.
_cam1.GetImage().ExitLock();
IsSrc1Dirty = false;
}
}
}
Camera CreateCamera(CameraDeviceInfo device)
{
try
{
if (device.SelectedStreamingFormat == ImageFormat.Argb)
{
return new VideoOverlayCamera(true);
}
if (device.SelectedStreamingFormat == ImageFormat.FlirFileFormat)
{
return new ThermalCamera(true);
}
}
catch (Exception e)
{
MessageBox.Show("Missing Atlas dependencies:" + e.Message);
Close();
}
throw new ArgumentOutOfRangeException("Unsupported streaming format");
}
private void buttonSource1_Click(object sender, EventArgs e)
{
// Connect to a camera
var device = ShowDiscovery();
if (device == null) return;
if (_cam1 != null)
{
_cam1.GetImage().Changed -= MainWindow_Src1Changed;
_cam1.ConnectionStatusChanged -= _cam1_ConnectionStatusChanged;
_cam1.Disconnect();
}
_cam1 = CreateCamera(device);
// Subscribe to the image changed event. Event driven gui.
_cam1.GetImage().Changed += MainWindow_Src1Changed;
_cam1.ConnectionStatusChanged += _cam1_ConnectionStatusChanged;
_cam1.Connect(device);
}
void _cam1_ConnectionStatusChanged(object sender, Flir.Atlas.Live.ConnectionStatusChangedEventArgs e)
{
BeginInvoke((Action) (() => labelStatusSrc1.Text = e.Status.ToString()));
}
static CameraDeviceInfo ShowDiscovery()
{
var dlg= new DiscoveryDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
return dlg.SelectedCameraDevice;
}
return null;
}
static void SaveSnapshot(Camera camera, string path)
{
try
{
camera.GetImage().EnterLock();
if (camera.ConnectionStatus == ConnectionStatus.Connected)
{
camera.GetImage().SaveSnapshot(path);
}
}
catch (Exception exception)
{
MessageBox.Show("Failed to save snapshot: " + exception.Message);
}
finally
{
camera.GetImage().ExitLock();
}
}
private void buttonSaveImage_Click(object sender, EventArgs e)
{
// save snapshot from both sources in selected location.
// create auto filename based on current date and time.
DateTime now = DateTime.Now;
string filenameSrc1 = textBoxImageLocation.Text + "\\" + now.ToString("yyyy-MM-ddTHHmmssfff") + "_src1";
if (_cam1 != null)
{
SaveSnapshot(_cam1, filenameSrc1);
}
}
private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
if (_cam1 != null)
{
_cam1.ConnectionStatusChanged -= _cam1_ConnectionStatusChanged;
_cam1.Disconnect();
}
}
private void buttonDisconnectSrc1_Click(object sender, EventArgs e)
{
if (_cam1 != null)
{
_cam1.Disconnect();
}
}
private void pictureBoxSource1_Click(object sender, EventArgs e)
{
}
private void textBoxImageLocation_TextChanged(object sender, EventArgs e)
{
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void labelStatusSrc1_Click(object sender, EventArgs e)
{
}
}
}
Webform code with just a few buttons
<%@ Page Title="Câmera" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Contact.aspx.cs" Inherits="IdReitz.Contact" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<h2><%: Title %>.</h2>
<h3>Testando a Câmera</h3>
<div>
<asp:Panel ID="Panel1" runat="server" Height="168px">
<asp:Button runat="server" OnClick="ConectaCamera" Text="Conectar Câmera" CssClass="btn btn-default" Height="27px" />
<asp:Button runat="server" OnClick="SalvarImagem" Text="Capturar Imagem" CssClass="btn btn-default" />
<asp:Button runat="server" OnClick="DesconectaCamera" Text="Desconectar" CssClass="btn btn-default" />
<br />
<br />
Localização da imagem:
<asp:TextBox ID="textBoxImageLocation" runat="server" Height="19px" Width="224px"></asp:TextBox>
<br />
</asp:Panel>
</div>
Webform C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Flir.Atlas.Image; -------Essa referencia ele não reconhece --------
using Flir.Atlas.Live.Device;
using Flir.Atlas.Live.Discovery;
namespace IdReitz
{
public partial class Camera : Page
{
private Camera _cam1;
private bool IsSrc1Dirty { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ConectaCamera(object sender, EventArgs e)
{
// Connect to a camera
var device = ShowDiscovery();
if (device == null) return;
if (_cam1 != null)
{
_cam1.GetImage().Changed -= MainWindow_Src1Changed; *******ERRO*******
_cam1.ConnectionStatusChanged -= _cam1_ConnectionStatusChanged; *******ERRO*******
_cam1.Disconnect(); *******ERRO*******
}
_cam1 = CreateCamera(device);
// Subscribe to the image changed event. Event driven gui.
_cam1.GetImage().Changed += MainWindow_Src1Changed; *******ERRO*******
_cam1.ConnectionStatusChanged += _cam1_ConnectionStatusChanged; *******ERRO*******
_cam1.Connect(device); *******ERRO*******
}
protected void SalvarImagem(object sender, EventArgs e)
{
// save snapshot from both sources in selected location.
// create auto filename based on current date and time.
DateTime now = DateTime.Now;
string filenameSrc1 = textBoxImageLocation.Text + "\\" + now.ToString("yyyy-MM-ddTHHmmssfff") + "_src1";
string filenameSrc2 = textBoxImageLocation.Text + "\\" + now.ToString("yyyy-MM-ddTHHmmssfff") + "_src2";
if (_cam1 != null)
{
SaveSnapshot(_cam1, filenameSrc1);
}
}
static CameraDeviceInfo ShowDiscovery()
{
var dlg = new DiscoveryDialog(); *******ERRO*******
if (dlg.ShowDialog() == DialogResult.OK) *******ERRO*******
{
return dlg.SelectedCameraDevice;
}
return null;
}
void MainWindow_Src1Changed(object sender, Flir.Atlas.Image.ImageChangedEventArgs e)
{
IsSrc1Dirty = true;
}
Camera CreateCamera(CameraDeviceInfo device)
{
try
{
if (device.SelectedStreamingFormat == ImageFormat.Argb)
{
return new VideoOverlayCamera(true); *******ERRO*******
}
if (device.SelectedStreamingFormat == ImageFormat.FlirFileFormat)
{
return new ThermalCamera(true); *******ERRO*******
}
}
catch (Exception e)
{
MessageBox.Show("Missing Atlas dependencies:" + e.Message);
Close(); *******ERRO*******
}
throw new ArgumentOutOfRangeException("Unsupported streaming format");
}
static void SaveSnapshot(Camera camera, string path)
{
try
{
camera.GetImage().EnterLock(); *******ERRO*******
if (camera.ConnectionStatus == ConnectionStatus.Connected) *******ERRO*******
{
camera.GetImage().SaveSnapshot(path); *******ERRO*******
}
}
catch (Exception exception)
{
MessageBox.Show("Failed to save snapshot: " + exception.Message);
}
finally
{
camera.GetImage().ExitLock(); *******ERRO*******
}
}
protected void DesconectaCamera(object sender, EventArgs e)
{
if (_cam1 != null)
{
_cam1.Disconnect(); *******ERRO*******
}
}
}
}
The Error you are presenting is:
Server Error in Application '/'.
Unable to load file or Assembly 'Flir.Atlas.Image' or one of its dependencies. An attempt was made to load a program with an incorrect format.
..
Description: An untreated exception occurred during the execution of current web request. Examine stack tracking to get more information about the error and where it originated in the code.
Exception Details: System.Badimageformatexception: Unable upload file or Assembly 'Flir.Atlas.Image' or one of your own dependencies. An attempt was made to load a program with an incorrect format.
Error of Origin:
Untreated exception was generated during the current execution web request. The information related to the origin and location of the exception can be identified by using stack tracking exception below.
Assembly Loading Tracking: The following information may be useful in determining why Assembly 'Flir.Atlas.Image' could not be loaded.
=== Information on pre-association status ===
LOG: Displayname = Flir.Atlas.Image (Partial) AVI: information from partial membership has been provided for an Assembly: AVI: Name of Assembly: Flir.Atlas.Image | Domain ID: 2 AVI: an association partial occurs when only part of the Assembly display name is provided. AVI: this can cause the associator to load a incorrect Assembly. AVI: It is recommended to provide an identity fully specified textual for Assembly, AVI: which consists of simple name, version, culture and public key token. AVI: See the white paper http://go.microsoft.com/fwlink/? Linkid=109270 for more information and common solutions to the problem. LOG: Appbase = file://c:/users/Reitz/Documents/visual studio 2015/Projects/Idreitz/Idreitz/ LOG: Initial Privatepath = c: users Reitz Documents visual studio 2015 Projects Idreitz Idreitz bin Calling Assembly: (Unknown). === LOG: this association starts in the default upload context. LOG: using application configuration file: c: users Reitz Documents visual studio 2015 Projects Idreitz Idreitz web.config LOG: using host configuration: C: Users Reitz Documents Iisexpress config aspnet.config LOG: using configuration file of the machine C: Windows Microsoft.NET Framework v4.0.30319 config machine.config. LOG: the policy is not being applied for reference at this time (particular, customized, partial or Assembly based association in local). LOG: trying to download new URL file://C:/Users/Reitz/Appdata/Local/Temp/Temporary ASP.NET Files/root/d05ad712/6abf2cb8/Flir.Atlas.Image.DLL. LOG: trying download a new URL file://C:/Users/Reitz/Appdata/Local/Temp/Temporary ASP.NET Files/root/d05ad712/6abf2cb8/Flir.Atlas.Image/Flir.Atlas.Image.DLL. LOG: trying to download new URL file://c:/users/Reitz/Documents/visual studio 2015/Projects/Idreitz/Idreitz/bin/Flir.Atlas.Image.DLL. ERR: failure to complete Assembly configuration (hr = 0x8007000b). Probing closed.
Cell Trace:
[Badimageformatexception: Unable to upload file or Assembly 'Flir.Atlas.Image' or one of its dependencies. A attempt to load a program with an incorrect format.]
System.Reflection.Runtimeassembly. _nLoad(Assemblyname filename, String codebase, Evidence assemblySecurity, Runtimeassembly locationHint, Stackcrawlmark & stackMark, Intptr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.Runtimeassembly.nLoad(Assemblyname filename, String codebase, Evidence assemblySecurity, Runtimeassembly locationHint, Stackcrawlmark & stackMark, Intptr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +36
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, Runtimeassembly reqAssembly, Stackcrawlmark & stackMark, Intptr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
System.Reflection.Runtimeassembly.Internalload(String assemblyString, Evidence assemblySecurity, Stackcrawlmark& stackMark, Intptr pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.Runtimeassembly.Internalload(String assemblyString, Evidence assemblySecurity, Stackcrawlmark& stackMark, Boolean forIntrospection) +21 System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.Loadassemblyhelper(String assemblyName, Boolean starDirective) +38[Configurationerrorsexception: Unable to load file or Assembly 'Flir.Atlas.Image' or one of its dependencies. A attempt to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.Loadassemblyhelper(String assemblyName, Boolean starDirective) +738
System.Web.Configuration.CompilationSection.Loadallassembliesfromappdomainbindirectory() +217 System.Web.Configuration.CompilationSection.Loadassembly(Assemblyinfo ai) +130
System.Web.Compilation.BuildManager.Getreferencedassemblies(Compilationsection compConfig) +170
System.Web.Compilation.BuildManager.Getprestartinitmethodsfromreferencedassemblies() +92 System.Web.Compilation.BuildManager.Callprestartinitmethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +290
System.Web.Compilation.BuildManager.Executepreappstart() +157
System.Web.Hosting.HostingEnvironment.Initialize(Applicationmanager appManager, Iapplicationhost appHost, Iconfigmappathfactory configMapPathFactory, Hostingenvironmentparameters hostingParameters, Policylevel policyLevel, Exception appDomainCreationException) +531[httpexception (0x80004005): Unable to load file or Assembly 'Flir.Atlas.Image' or one of its dependencies. A attempt to load a program with an incorrect format.]
System.Web.Httpruntime.Firstrequestinit(Httpcontext context) +9963380 System.Web.Httpruntime.Ensurefirstrequestinit(Httpcontext context) +101 System.Web.Httpruntime.Processrequestnotificationprivate(Iis7workerrequest Wr, Httpcontext context) +254
Version Information: Microsoft . NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0
Basically it would not only be you add the dll of Flir.Atlas.Image?
– Pablo Tondolo de Vargas
@Pablovargas I already added and continues the same error, as if I had not put but it is there in the code: using Flir.Atlas.Image; -------This reference he does not recognize -------
– Lorena
This Filr.Atlas would not only be compatible with Winforms project?
– Pablo Tondolo de Vargas
Lorena , from what I could see some things are missing, for example
_cam1.GetImage().Changed -= MainWindow_Src1Changed; *******ERRO*******
... this must be a method that this missing (MainWindow_Src1Changed
) ... try to remove or comment on the parts that are wrong and do it slowly– Marco Souza
Another thing the Conectacamera ... Camera would be a camera from a device a web cam ? this will work the same way in the web application?
– Marco Souza
try to create questions as brief as possible to not have negative votes or even end the closed question.
– Marco Souza
@Marconciliosouza Yes, is a thermal imager, these dlls are provided by the camera manufacturer the Getimage function is in dll Flir.Atlas.Image which is not being recognized as if I had not inserted it.
– Lorena
@Pablovargas does not know if it is compatible only with Winforms pq is made available by the camera manufacturer company.
– Lorena
@Lorena, from what I noticed on the website of Flir this dll is supported in vicsual studio 2015 in version 2.6. see if it is in the correct version. and as I said before, try to create questions with one or two errors , and very detailed, you can create as many questions as you want as long as they are not of the same subject. http://flir.custhelp.com/app/answers/detail/a_id/1043/~/how-can-i-get-access-to-Flir-atlas-sdk-4.x-%3F
– Marco Souza
@Marconciliosouza this version 2.6 would be version of what? the visual studio I’m using is 2015.
– Lorena
Let’s go continue this discussion in chat.
– Marco Souza