Click here to Skip to main content
15,867,488 members
Home / Discussions / C#
   

C#

 
GeneralRe: Interacting with a Page Web Service (OData v4) Error Pin
Gerry Schmitz4-Jan-17 21:19
mveGerry Schmitz4-Jan-17 21:19 
GeneralRe: Interacting with a Page Web Service (OData v4) Error Pin
MaWeRic4-Jan-17 23:12
MaWeRic4-Jan-17 23:12 
GeneralRe: Interacting with a Page Web Service (OData v4) Error Pin
MaWeRic5-Jan-17 1:00
MaWeRic5-Jan-17 1:00 
GeneralRe: Interacting with a Page Web Service (OData v4) Error Pin
Gerry Schmitz5-Jan-17 5:23
mveGerry Schmitz5-Jan-17 5:23 
GeneralRe: Interacting with a Page Web Service (OData v4) Error Pin
MaWeRic5-Jan-17 8:00
MaWeRic5-Jan-17 8:00 
GeneralRe: Interacting with a Page Web Service (OData v4) Error Pin
Gerry Schmitz5-Jan-17 8:25
mveGerry Schmitz5-Jan-17 8:25 
GeneralRe: Interacting with a Page Web Service (OData v4) Error Pin
MaWeRic5-Jan-17 8:26
MaWeRic5-Jan-17 8:26 
QuestionGlobal structure in Main, Functions and .dlls Pin
zequion3-Jan-17 21:58
professionalzequion3-Jan-17 21:58 
I have a class called Cls_Common.cs which contains a structure called St_Common where I declare the global variables that are common to all .cs files. I use it in Functions, compiled classes .dlls and in Mains.

I create a compiled .dll class to encrypt using these functions and the global structure of Cls_Common.cs.

When i add by reference the compiled class .dll to a Main, in the compile it generates in Visual Studio, there are actually two versions of the file Cls_Common.cs. When doing =new of the global structure, an ambiguity error occurs but execution continues and when an attempt to assign or retrieve a global structure value, occurs an error exception.

Issue:
In order to compile the Cls_Encrypt.dll class I need to include Cls_Common.cs to use common functions. At Main that includes by reference Cls_Encrypt.dll I also need to include Cls_Common.cs and that produces ambiguity.

According to Microsoft's brief solution to error CS0433, you have to compile from the command line with /reference and use an alias:
: https://msdn.microsoft.com/es-es/library/64wh5743.aspx
// compile with: /reference:cs0433_1.dll /reference:TypeBindConflicts=cs0433_2.dll
C#
using TypeBindConflicts;  
public class Test   
{  
   public static void Main()   
   {  
      AggPubImpAggPubImp n6 = new AggPubImpAggPubImp();  
   }  
}
My Program:
==========

Cls_Common.cs:
----------------
C#
namespace Name_Common
{
    public struct St_Common
    {   
       public string Languaje;
    }

    public static partial class Cls_Common
    {   // I define the structure so that there is no error in compiling.
        public static Name_Common.St_Common StCommon;
    }
}
Class compiled in an assembly called Cls_Encrypt.dll This class uses in Mains adding it as reference. Used to encrypt. Inside the class, calls are made to functions such as Func1.cs, Func2.cs ... That use the global variable structure Name_Common.Cls_Common.StCommon

Cls_Encrypt.cs:
C#
---------------
public class Cls_Encrypt
{
    public Cls_Encrypt()  // Constructor.
    {  // Example line:
       if (Name_Common.Cls_Common.StCommon.Languaje == "Eng") ... 
    }
}
Main where I added as reference to compiled class Cls_Encrypt.dll

Main.cs
-----------
C#
namespace Name_Main
{
    public Cls_Main() 
    {
       // At this line, no error event occurs. But if in the debugger I query by Name_Common.Cls_Common.StCommon, it appears:
       // Name_Common.Cls_Common.StCommon error CS0433: type 'Cls_Common' exists in 'Cls_Encrypt, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and in 'Main, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'

       Name_Common.Cls_Common.StCommon = new Name_Common.St_Common();

       // The execution continues, but in the line:
       string MyVar = Name_Common.Cls_Common.StCommon.Languaje;

       // The exception occurs:
       // + ErrorExcp {"Object reference not set to an instance of an object."} System.Exception {System.NullReferenceException} HResult -2147467261
    }
}
The solution of Microsoft does not serve me because I have to leave Visual Studio to compile from the command line every time I make a change and the solution serves in the main but the functions do not refer to the alias. The solution seems like a fix.

It does not help me to pass by reference the global structure from the main to .dll because to compile the .dll I need to reference the type of the global structure of Cls_Common.cs. In addition, I would need to go through many structures because the .cs functions
are many and require new and different variables. Need global structures, not references.

I ask this:
1.- How can I use a single copy of a global structure in a compiled class .dll and in a main.
2.- When I use the Visual Studio debugger, if the form is large I can not see the code below. How to hide the form?
3.- I have read that I can stop the execution in the debugger (F9) and that I can press Interrupt, Modify a line and Continue. But he will not let me interrupt. How is made? Because now I have to stop the execution and start again.

I do not understand how this problem occurred when it is logical to use a global structure in Main, Functions and .dlls

Thank you.

modified 4-Jan-17 12:56pm.

AnswerRe: Global structure in Main, Functions and .dlls Pin
Richard MacCutchan3-Jan-17 23:32
mveRichard MacCutchan3-Jan-17 23:32 
GeneralRe: Global structure in Main, Functions and .dlls Pin
zequion4-Jan-17 1:11
professionalzequion4-Jan-17 1:11 
GeneralRe: Global structure in Main, Functions and .dlls Pin
Richard MacCutchan4-Jan-17 1:16
mveRichard MacCutchan4-Jan-17 1:16 
GeneralRe: Global structure in Main, Functions and .dlls Pin
zequion4-Jan-17 6:41
professionalzequion4-Jan-17 6:41 
GeneralRe: Global structure in Main, Functions and .dlls Pin
Richard MacCutchan4-Jan-17 6:47
mveRichard MacCutchan4-Jan-17 6:47 
GeneralRe: Global structure in Main, Functions and .dlls Pin
zequion4-Jan-17 7:57
professionalzequion4-Jan-17 7:57 
GeneralRe: Global structure in Main, Functions and .dlls Pin
Richard MacCutchan4-Jan-17 21:27
mveRichard MacCutchan4-Jan-17 21:27 
AnswerRe: Global structure in Main, Functions and .dlls Pin
Gerry Schmitz4-Jan-17 7:52
mveGerry Schmitz4-Jan-17 7:52 
Questionhow to store the value selection on calendar in database Pin
being A.S.3-Jan-17 18:37
being A.S.3-Jan-17 18:37 
AnswerRe: how to store the value selection on calendar in database Pin
dan!sh 3-Jan-17 19:55
professional dan!sh 3-Jan-17 19:55 
QuestionRetrieving data from a webpage Pin
MAW303-Jan-17 13:46
MAW303-Jan-17 13:46 
AnswerRe: Retrieving data from a webpage Pin
dan!sh 3-Jan-17 17:30
professional dan!sh 3-Jan-17 17:30 
GeneralRe: Retrieving data from a webpage Pin
MAW303-Jan-17 19:01
MAW303-Jan-17 19:01 
GeneralRe: Retrieving data from a webpage Pin
dan!sh 3-Jan-17 19:53
professional dan!sh 3-Jan-17 19:53 
GeneralRe: Retrieving data from a webpage Pin
MAW303-Jan-17 21:28
MAW303-Jan-17 21:28 
GeneralRe: Retrieving data from a webpage Pin
dan!sh 3-Jan-17 22:01
professional dan!sh 3-Jan-17 22:01 
GeneralRe: Retrieving data from a webpage Pin
MAW304-Jan-17 4:43
MAW304-Jan-17 4:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.