Results 1 to 6 of 6

Thread: Circular Dependency problem

  1. #1
    Join Date
    Nov 2009
    Posts
    47

    Circular Dependency problem

    I have the following question:

    I have a program written in Clarion. This program can use the Windows API. So I have a web service library written in C#. To get the application to Clarion to call methods in C # project so I made a C++ wrapper. The way I talk with C++ wrapper for the Clarion is through a C++ Interface. Clarion can actually refer directly to C++ interfaces. This is good, and works like a charm.

    And C++ can call the Clarion's Interfaces directly in the same way. In other words, a two-way communication between C++ and Clarion.

    Then comes the problem. I will call the Clarion functions from C # page. I would like to use C++ wrapper for this because it has already set up a connection between the Clarion program and the C # library, but when I try to adding C++ project to C # project but I get Circular Dependencies messages, which is understandable.

    My first thought was to compose a new C # library project, which would refer to C++ library, but Visual Studio is just too smart. It stops me when I try to put this project into the reference list of C # program. Could not fool Visual Studio here.

    Please help!

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Circular Dependency problem

    Do not know if you have the opportunity to implement such. C++ interfaces in Clarion. But then more you could make a dll with all the interfaces to be used over the "interface" between the Clarion and C++. And for that matter also between C++ and C #. You can then create a factory or what I call an "application context" that sews together the program itself. And who is to communicate with what. In other words, all DLLs independent outside a shared dll in the bottom. At the top you have a main dll that sews together the program.

    In my case I have a dll with common interfaces to be implemented by objects which shall be evidence only, searchable, etc. I have DLLs on top 5-6. That are independent of each other. While .exe file on the top adds to the character only objects from the different DLLs in a Draw Able list since they all implement a common interface from DLL.

  3. #3
    Join Date
    Nov 2009
    Posts
    47

    Re: Circular Dependency problem

    That is not my problem between C + + and Clarion. Let me simplify it even more. Forget Clarion throughout this.

    Project 1, which generates the .exe file that is in C + +
    Project 2, which generates .NET code that is in C #

    Project 1 uses Project 2 uses features
    Project 1 includes features that project 2 will have

    How would you solve this?

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Circular Dependency problem

    1: Add all the interfaces for both project 1 and 2 in a shared dll (project 3)
    2: Implement interfaces from project 3 in projects 1 and 2
    3. Project 1 sets up the objects in the project 2 via dependency injection with interfaces defined in the Project 3 This means that the project does not reference the project 2 1 but it uses the code through interfaces that are defined in Prosjekt3.
    4: Ideally, I would set up a Project (exe) as a dll and had dll on top that connects the objects in the DI.

    With this solution you will get 4 assembly

    1, Exe
    2. Dll logic
    3. Dll logic
    4. Dll common interfaces for the two to be able to call 3 and vice versa.

    1. Refers 2.3 and 4
    2, 4 Refers
    3. Refers 4
    4. Refers no

    An alternative "pig way" to do it is to connect 1 to 2 of hard wiring and 2 can load objects from 1 via System.Reflection and throw them to the interfaces defined in Project 2 with such a solution avoids defining additional DLL that I suggest above.

  5. #5
    Join Date
    Nov 2009
    Posts
    47

    Re: Circular Dependency problem

    Thanks... But then comes the question of interfaces and C + + / C #. How can I use a C + + Interface in C #? To draw in Clarioin again so is the way I do it this way:

    in Clarion:
    CWrapperInterface & = Api_CDLL_GetInterface (Self.CallbackInterface)

    Self.CallbackInterface there is an interface defined in Clarion as C++ can read and c++ returns its own interface, which I store in CWrapperInterface.

    Would therefore like Kunena made some of the same with C#. This means that C++ DLL must be able to do something like this:

    ThisNetWrapper = NETManager:: GetInterface (ThisCInterface);

    and in C# code, I want something like:

    public iNetWrapper GetInterface (iCInterfaceType pCInterface)
    {
    this.cWrapper = pCInterface;
    return this.NetWrapperInterface;
    }

    Is it possible? I guess the more that it must be possible since you say that communication must go via an interface, which I already do the C++ and Clarion.

  6. #6
    Join Date
    May 2008
    Posts
    2,389

    Re: Circular Dependency problem

    Code:
    public interface MyInterface
    {
      float InterfacePropertyOne { get; set; }
    
      int InterfaceMethodOne();
    
      string InterfaceMethodTwo();
    }
    
    Implementing properties in managed C++ is fairly similar to C#. Here's the new C++ implementation of the interface.
    
    public ref class Class1 : public CSharpLib::MyInterface
    {
    public:
      virtual int InterfaceMethodOne() { return 0; };
    
      virtual System::String^ InterfaceMethodTwo() {return ""; };
    
      virtual property float InterfacePropertyOne
      {
        void set(float value) { };
        float get() { return 0; };
      };
    };
    Here, however, implemented a C# interface in C++. But there should be no problem going the way candidates either. Whether this solves the problem if you define all the interfaces in C#

    But as long as you add CLR support in C++ DLL there should be no problem going both ways.

Similar Threads

  1. Replies: 2
    Last Post: 21-02-2012, 12:59 PM
  2. Circular Reference Problem
    By timpatmc in forum Microsoft Project
    Replies: 2
    Last Post: 30-04-2011, 03:01 AM
  3. Circular Kernel context logger
    By jhon in forum Windows Software
    Replies: 5
    Last Post: 07-04-2010, 07:17 AM
  4. A circular reference exists - Error
    By pushpendra in forum Microsoft Project
    Replies: 4
    Last Post: 29-07-2009, 10:36 PM
  5. What is Circular dependency?
    By Kiran123 in forum Software Development
    Replies: 3
    Last Post: 19-02-2009, 06:44 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,859,712.59549 seconds with 17 queries