Erstellen eines Application Objekts

Erstellen eines Application Objekts

Hallo,
ich stehe vor dem Problem innerhalb einer Windows-Form auf die Klasse ThisProject, zur Verwendung von „this“, zugreifen zu wollen (Quellcode in C#). Mir wurde nun erklärt, dass dies mit der Erstellung eines eigenen zenon.application Objekts in der Klasse zu verwirklichen wäre.
Nun führt dies beim ersten Aufruf der Application zu der Fehlermeldung:
„Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.“
Der Verweis führt zu einem Eintrag von „NULL“ in die OnlineVariable und dem Ausstritt aus der „try“.
Ach ja; unter der ThisProject Klasse funktionierte es…
Quellcode:
C# Code:
using System.Runtime.InteropServices;

namespace ProjectAddin
{
public partial class Form_Doku : Form
{
zenOn.Application zApp;
string[][] array = new string[500][];
string nameProject;
int d = 0;
public Form_Doku(string project)
{

InitializeComponent();
zApp = Marshal.GetActiveObject("zenOn.Application") as zenOn.Application;
language.Text = "deutsch";
language.Items.AddRange(new String[]{"deutsch", "english", "francais" });
projectName.Text = project;
nameProject = project;
}
private void start_Click(object sender, EventArgs e)
{
zenOn.IOnlineVariable zOnlineV;
try
{
///If OnlineVariable (Container) doesn't exist create a new one
zOnlineV = zApp.Projects().Item(nameProject).OnlineVariables().Item("myOnlineV");

if (zOnlineV == null)
{
zOnlineV = zApp.Projects().Item(nameProject).OnlineVariables().CreateOnlineVariables("myOnlineV"); //this.OnlineVariables().CreateOnlineVariables("myOnlineV");
}
[…]


This is a migrated post! Originally posted on 23.07.2014 by user seb. Please be aware that information can be outdated.

    Disclaimer

    This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.

    The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.

    Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.

    Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.

    COPA-DATA reserves the right to change this document from time to time at own discretion.


    Ing. Punzenberger COPA-DATA GmbH
    Karolingerstraße 7b · 5020 Salzburg · Austria
    www.copadata.com