-1

I have written a code in c++ and c# . From my c++ code i am calling my c# function through. I have sent just a part of c++ code.

txtPath contains the location of a text file. C++ code:

    CoInitialize(NULL);
    IMyClassPtr obj3;
    obj3.CreateInstance(__uuidof(Program));
    obj3->Validation(txtPath);
    CoUninitialize();

Validation() is my c# function. My c# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using word = Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace ABC
{
    [ComVisible(true)]
    public interface IMyClass
    {
        void Validation(string txtp);

    }


    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]

    public class Program : IMyClass
    {


        private string replace_string(string text)
        {
            return text.Replace("\r\a", "");
        }

        public void Validation(string txtp)
        {
            string[] textValidate = File.ReadAllLines(txtp);
            string textpath = txtp;
            //validation starts here
            foreach (string line in textValidate)
            {
                string[] strsplit = line.Split(new string[] { "," }, StringSplitOptions.None);
                string task = strsplit[0];
                string sign = strsplit[1];
                string person = strsplit[2];
                string routing = strsplit[3];

                if (String.IsNullOrEmpty(task) || String.IsNullOrEmpty(sign) || String.IsNullOrEmpty(person))
                {
                    //if the txt file is invalid
                    MessageBox.Show("Signature.txt is incomplete or has invalid input!!!");

                }


            }

        }
}
}

I have done all the required setting in c# .C# settings snapshot C# project is a class library. My code was working perfectly in 32 bit machine. I was using the generated tlb in other systems by registering it with regasm.exe.

In 64 bit machine by c++ code is working but when the c# linking code is hit the execution stops without throwing any error. I am using a 64 bit machine and created a new project with the same code. Help Please

shrey
  • 1
  • 4

2 Answers2

0

On 64-bit Windows, Microsoft does not support loading a 64-bit DLL into a 32-bit process, or vice-versa. For additional information, please refer to the following resource on MSDN:

http://msdn.microsoft.com/en-us/library/aa384231(VS.85).aspx

Jacob Seleznev
  • 7,802
  • 3
  • 20
  • 33
0

Make you're using the correct version of 'regasm.exe' for your target platform (i.e. "C:\Windows\Microsoft.NET\Framework64\v2.0.50727\RegAsm.exe"). Take note of 'Framework64'.