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 4271318
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:25:33+00:00 2026-05-21T07:25:33+00:00

here and here they do talk about what to do, but i seem to

  • 0

here and here they do talk about what to do, but i seem to be unable to find my c# project in c++.

I have added the c# project as a reference in the c++ project but whenever i try to use the method i need, it can’t find the namespace. i have added it by right clicking the c++ project and going for ‘reference’ then added the c# project with add new reference. both projects are in the same solution.

In the below code excamples i have given the full c# code (except for usings) and a part of the c++ code (the method where i am trying to call the c# method from). I have also changed some of the namespacing to be more generic and contain no sensitive information.

the c# code is like this.

namespace Company.Pins.Bank.Decryption
{

    public class Decrypt
    {       
        [DllImport("decryptsn.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern IntPtr decryptsn(byte[] InpData);
        //__declspec(dllimport) char* decryptsn(char* InpData);

        public static String Decryption(string param2)
        {
            byte[] InpData = new byte[255];
            InpData = StrToByteArray(param2);    
            return Marshal.PtrToStringAnsi(decryptsn(InpData));
        }

        public static byte[] StrToByteArray(string str)
        {
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            return encoding.GetBytes(str);
        }    
    }
}

C++ code

CPReSInterfaceApp theApp;

extern "C" DllExport BOOL WINAPI UserInstruction(
                    HWND hWnd, HINSTANCE hInst, double* lpNumeric, 
                    TCHAR* lpAlpha1, TCHAR* lpAlpha2)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

    if (lpNumeric == NULL || lpAlpha1 == NULL || lpAlpha2 == NULL)
        return FALSE;

    ReconcileUHParameter(lpNumeric, lpAlpha1, lpAlpha2);

    int iCommand = (int)lpNumeric[0]; 

    lpNumeric[0] = 6;
    lpAlpha2 = Company.Pins.Bank.Decryption.Decrypt.Decryption("123456");

    return TRUE;
}
  • 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-21T07:25:33+00:00Added an answer on May 21, 2026 at 7:25 am

    You need to add a #using directive to the code. For example, if your C# dll were named Decrypt.dll, add this to the top of your C++ compiland:

    #using "Decrypt.dll"
    

    You also need to make sure the C++ code that calls a managed method is also compiled as managed using the /clr compiler option.

    Also, I believe you need to use :: as a namespace separator, rather than ..

    lpAlpha2 = Company::Pins::Bank::Decryption::Decrypt::Decryption("123456");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

They always talk about extendability and flexibility when writing code, but here I am
There is a nice discussion of generics here But they all talk about how
How can I do what they are talking about here , but in Ruby?
I have read the other questions and they mostly talk about the security of
Going through the microsoft authentication tutorial listed here they have you create a master
I work for a travel agency, they have a website, from here they want
Here are two different questions but I think they are related. When using Git,
Here is the man page for git show-ref -d . They also have an
Here is the main scroller. The stream view. But how did they implement this?
So here is the problem. I have a method (or message as they are

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.