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

  • Home
  • SEARCH
  • 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 6785859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:10:38+00:00 2026-05-26T17:10:38+00:00

I have compiled and built a DLL project in VS 2010. I have an

  • 0

I have compiled and built a DLL project in VS 2010. I have an added sister-project to the same solution which will essentially link to the above DLL and need to load its constructor and functionalities. However, as soon as I am trying to instantiate the object, it gives access violation.

In main, I do this..

#include <iostream>
#include "MCaromDLL.h"

using namespace std;
using namespace MagneticCarom;

int main() {
    . . .
    MagneticCaromWrapper wrapper;
        . . .
}

My “MCaromDLL.h” looks like this:

// MCaromDLL.h

#define NULL 0
#define MAX_COLS 201        //Fixed based on the FEMM values
#define MAX_ROWS MAX_COLS   //Fixed based on the FEMM values

#ifdef DLL_PROJECT 
#define DLLSPEC __declspec(dllexport)
#else
#define DLLSPEC __declspec(dllimport)
#endif

#ifndef __MCAROMDLL_H__
#define __MCAROMDLL_H__

namespace MagneticCarom
{
    . . . . . . .
    class DLLSPEC MagneticCaromWrapper
    {
        private:
                       //All private members here...            

        public:
            MagneticCaromWrapper();

            MagneticCaromWrapper(int number);

            virtual ~MagneticCaromWrapper();

                        //remaining functions
    }
}
#endif

Note that I am trying to export the entire class (although I tried exporting individual funcs also, but in vain) now. The entire code can be made available on request.

  • 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-26T17:10:39+00:00Added an answer on May 26, 2026 at 5:10 pm

    Its always an issue to handle memory or structs over dll interface.
    Things that can go wrong:

    • Different runtime
    • Different allignment
    • Overloaded new …

    To make sure it works:
    – Use a pure virtual interface
    – Use a factory method
    – Use a delete/release method

    IMagneticCaromWrapper* DLLSPEC FactoryMagneticCaromWrapper();
    
    class IMagneticCaromWrapper
    {
    public:
        virtual void Release();
    }
    

    with an implementation.

    IMagneticCaromWrapper* DLLSPEC FactoryMagneticCaromWrapper()
    {
        return new MagneticCarom();
    }
    
    IMagneticCaromWrapper::Release()
    {
        delete this;
    }
    

    At best do not throw exceptions cross dll boundaries.

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

Sidebar

Related Questions

I have a project I have built in Visual Studio 2010 on a Windows
I have a VS2008 C++ project which currently I compiled on VS2010. it contains
I have a 2010 project that is targeting .NET v3.5. Inexplicably I can no
I have a Visual Studio 2010 project that is targeted to .NET Framework 3.5.
I have a C# project in which I have embedded an IronRuby program. The
I have a simple .NET dll built with VS2010 C# that exposes 2 static
Let's say we have a solution with the following structure: Project.DAL - Data access
I have a C++ DLL compiled natively and I'd like to write a CLR
I have a core project which I'm building as a shared library. In one
This is the first time I have attempted to create a .dll, that will

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.