Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6965821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:06:40+00:00 2026-05-27T16:06:40+00:00

We are migrating an application from C# to VB to meet our project’s needs

  • 0

We are migrating an application from C# to VB to meet our project’s needs but stumbled upon a problem with event handling in VB.

The application uses a COM Wrapper access a scanner in Silverlight. The object is created dynamically in the code, and an event is added to “AcquirePage”. This requires elevated trust of course.

Code in C#:

dynamic TwainSession;
(...)
TwainSession.AcquirePage += new AcquirePageDelegate(AcquirePageEventHandler);

As the only real “equivalent” of dynamic in VB is Object, we use:

Private TwainSession As Object

Everything is fine up to the point we want to handle an event of this Object. Because we are in Silverlight, we cannot have knowledge of the Object’s structure or events, hence the need to create it dynamically. In C# we simply use “+=” to add a handler to an event but:

AddHandler TwainSession.AcquirePage, AddressOf AcquirePageEventHandler

In VB gives: ‘AcquirePage’ is not an event of ‘Object’

Any way around that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:06:40+00:00Added an answer on May 27, 2026 at 4:06 pm

    Unable to find a solution to do this within VB, we went about it this way:

    1. Added a new project: Silverlight C# Class Library
    2. The constructor takes two arguments, the dynamic object and the address of the event handler, and performs the C# method of adding handlers:

      public TwainHandler(dynamic twainSession, Delegate eventHandler)
      {
      twainSession.AcquirePage += eventHandler;
      }

    3. The C# library was built and the dll added as a reference to the VB project.

      Dim t as TwainHandler = New TwainHandler(TwainSession, New AcquirePageDelegate(AddressOf AcquirePageEventHandler))

    This way the C# library adds the handler for the event (which points to a method in our VB application) dynamically. If anyone has a better solution please share.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently We are facing a lot of problem in migrating our Application from Hibernate
We've got a weird problem while migrating our app from 1.3.7 to 2.0.0. Our
We are currently in the process of migrating our application from our production environment
We are migrating our web application from Spring 2.5 to Spring 3.0.5. Looks like
We are migrating an application from VB6 to .net c#. The application uses a
I'm migrating an application from ColdFusion to ASP.Net MVC and have a little problem
Background: Migrating an application from ball of mud to MVC. Many classes contain HTML
I am migrating an application from .NET 1.1 to .NET 2.0. Should I remove
I'm currently working on migrating an application from MS-Access to MS SQL Server. In
What kinds of considerations are there for migrating an application from NHibernate 1.2 to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.