I'm trying to capture a webcam image using the emgucv library - vb.net

This code is giving an error : type capture not defined
Imports Emgu.Cv
Imports Emgu.Cv.UI
Imports Emgu.Cv.Structure
Public class Form 1
Dim webcam as New capture
I was expecting it to create a new capture object

Related

How to upload file with Asp.net Web Api project?

i have a web API project to be consumed from mobile applications and i was trying to make a file upload controller. there are few resources in C# and i don't find anything useful for VB.NET.
i tried this code below converting from c# to VB.NET, but says "Move is not a member of MultiPartFileData".
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Net
Imports System.Net.Http
Imports System.Threading.Tasks
Imports System.Web
Imports System.Web.Http
Namespace HelloWorld.Controller
Public Class FileUploadingController
Inherits ApiController
<HttpPost>
<Route("api/FileUploading/UploadFile")>
Public Async Function UploadFile() As Task(Of String)
Dim ctx = HttpContext.Current
Dim root = ctx.Server.MapPath("~/App_Data")
Dim provider = New MultipartFormDataStreamProvider(root)
Try
Await Request.Content.ReadAsMultipartAsync(provider)
For Each file In provider.FileData
Dim name = file.Headers.ContentDisposition.FileName
name = name.Trim(""""c)
Dim localFileName = file.LocalFileName
Dim filePath = Path.Combine(root, name)
File.Move(localFileName, filePath)
Next
Catch e As Exception
Return $"Error: {e.Message}"
End Try
Return "File uploaded!"
End Function
End Class
End Namespace
That error message means the compiler think that you are trying to call a method from the MultiPartFileData class. The variable of type MultiPartFileData is the one called file (notice the lowercase) initialized in the For Each loop.
Instead you want to call the Move method from the System.IO.File class (notice the uppercase).
VB.NET services (always running in background looking to catch errors while you type) is case insensitive so, for it, the two names are the same and here arises the error emitted when you code that line.
The best solution is to avoid names like file for your variables when you plan to use the class System.IO.File. Otherwise you could simply add the full qualified method's name in this way
System.IO.File.Move(localFileName, filePath)

How to Implement Custom Selenium WebElement FindElement

I want to create a custom WebElement from IWebElement and then implement FindElement to locate an element in my internal list of elements in m_Elements:
I have this snippet so far:
Imports OpenQA.Selenium
Imports OpenQA.Selenium.By
Imports System.Collections.ObjectModel
Imports System.Drawing
Imports System.Text.RegularExpressions
Public Class MyWebElement
Implements IWebElement
Private m_Elements As New List(Of MyWebElement)
Public Function FindElement(byObj As By) As IWebElement Implements ISearchContext.FindElement
'
End Function
If I look at byObj in Visual Studio I see:
Equals, FindElement, FindElements, GetHasCode, GetType, ToString.
If I look at byObj in the debugger I see:
Description, FindElementMethod, and FindElementsMethod
How do I determine what By class was used by the caller? By.Id, By.TagName, etc.
How do I get the SearchContext?

Connection String in VB.NET

How i can use ODP tool for oracle connection while working with VB.NET web service in the following web service in order to retrieve data from an oracle? The query that I would like to use is
SELECT ALIQUOT_ID FROM ALIQUOT
<%# WebService Language="vb" Codebehind="Aliquot.asmx.vb" Class="Aliquot" %>
Imports System.Web
Imports System.Data
Imports System.Web.Services
Imports Oracle.DataAccess.Client
Imports System.Type
Imports System.Web.Services.Protocols
Imports System.Configuration
Imports System.Configuration.ConfigurationManager
<WebService([Namespace]:="http://myservices.com/webservices/")> _
Public Class Aliquot
Inherits System.Web.Services.WebService
<WebMethod(Description:="Get Aliquot_IDs from Aliquot table")> _
Public Function GetAliquot_ID(ByVal aliquot_id As Integer) As Integer
Return (aliquot_id)
End Function
End Class

Exception Dts is not declared

I'm getting this (Dts is not declared) exception when I try to build my SSIS script task. Any idea how to resolve it?
here is the part of my code
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Try
Dim cm As ConnectionManager = Dts.Connections.Add("FTP")
cm.Properties("ServerName").SetValue(cm, Dts.Variables("SFTPServerName").Value.ToString)
cm.Properties("ServerUserName").SetValue(cm, Dts.Variables("SFTPLogin").Value.ToString)
cm.Properties("ServerPassword").SetValue(cm, Dts.Variables("SFTPPassword").Value.ToString)
cm.Properties("ServerPort").SetValue(cm, Dts.Variables("SFTPPortNumber").Value.ToString)
This worked for me:
Add Your_Variable in the script component. (Right click --> Edit --> Script --> ReadOnlyVariables).
Dim variableString As String = Me.ReadOnlyVariables("User::Your_Variable").Value.ToString().
Try adding;
Imports Microsoft.SqlServer.Dts
Try me.Connections and me.Variables

Error in a strongly typed view

I have a MVC3 application which uses Devexpress controls.
My first page works fine, but this is not strongly typed.
I get the error "BC30451: 'ViewData' is not declared. It may be inaccessible due to its protection level" on my second page which starts with:
#ModelType IEnumerable(Of MyModel.XXX)
#Code
ViewBag.Title = "Index"
End Code
<h2>Index</h2>
The resulting vb code inherits from System.Web.Mvc.WebViewPage.
Is there a problem with the imports???
#ExternalChecksum("C:\Work\XXX\Views\FahrzeugMarke\Index.vbhtml","{406ea660-64cf-4c82-b6f0-42d48172a799}","A585D67D9E053939A220E5FDCF169863")
'------------------------------------------------------------------------------
' <auto-generated>
' Dieser Code wurde von einem Tool generiert.
' Laufzeitversion:4.0.30319.235
'
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
' der Code erneut generiert wird.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports DevExpress.Utils
Imports DevExpress.Web.ASPxCallbackPanel
Imports DevExpress.Web.ASPxClasses
Imports DevExpress.Web.ASPxEditors
Imports DevExpress.Web.ASPxGridView
Imports DevExpress.Web.ASPxHtmlEditor
Imports DevExpress.Web.ASPxMenu
Imports DevExpress.Web.ASPxNavBar
Imports DevExpress.Web.ASPxPopupControl
Imports DevExpress.Web.ASPxRoundPanel
Imports DevExpress.Web.ASPxSpellChecker
Imports DevExpress.Web.ASPxSplitter
Imports DevExpress.Web.ASPxTabControl
Imports DevExpress.Web.ASPxTreeView
Imports DevExpress.Web.ASPxUploadControl
Imports DevExpress.Web.Mvc
Imports DevExpress.Web.Mvc.UI
Imports MvcMiniProfiler
Imports System
Imports System.Collections.Generic
Imports System.IO
Imports System.Linq
Imports System.Net
Imports System.Web
Imports System.Web.Helpers
Imports System.Web.Mvc
Imports System.Web.Mvc.Ajax
Imports System.Web.Mvc.Html
Imports System.Web.Routing
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.WebPages
Namespace ASP
Public Class _Page_Views_FahrzeugMarke_Index_vbhtml
Inherits System.Web.Mvc.WebViewPage(Of IEnumerable(Of myModel.XXX))
Public Sub New()
MyBase.New
End Sub
Protected ReadOnly Property ApplicationInstance() As ASP.global_asax
Get
Return CType(Context.ApplicationInstance,ASP.global_asax)
End Get
End Property
Public Overrides Sub Execute()
WriteLiteral(""&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10))
#ExternalSource("C:\Work\XXX\Index.vbhtml",3)
ViewBag.Title = "Index"
I think I solved the problem:
I created the view with MvcScaffolding and the file was saved with ANSI encoding. However, there were German umlauts in my model class name and these got corrupted.
Changing the file encoding to UTF8 solved the issue...