logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
payrollproject  
#1 Posted : Friday, January 3, 2020 5:53:59 PM(UTC)
payrollproject

Rank: Member

Groups: Registered
Joined: 1/3/2020(UTC)
Posts: 11

Thanks: 2 times
I'm using Mono C#. I'm unable to reference the CenterPoint API.

Here is the error I'm getting:
"hello.cs(19,10): error CS0246: The type or namespace name 'DataAccessAPI' could
not be found (are you missing a using directive or an assembly reference?)"

Evidently there is some DLL (or import statement?) that I'm missing.

My code is below, but I don't think the code itself is very important since the code was generated automatically from CenterPoint's data browser tool. All I'm trying to do is run it.

How do I reference your DLLs?

Code:

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CenterPointDataBrowser;

namespace CenterPointDataBrowser
{
   public class ReportDataExample
   {
      public DataSet GetReportData()
      {
         string databaseName = "PayrollSample";
         string reportKey = "968465a0-1b3c-47b8-9b80-915ad2888037";

         // Initialize the API
         DataAccessAPI api = new DataAccessAPI();

         // Open the database
         api.OpenDatabase(databaseName); // there is an over-loaded method if you need to supply a user/name password

         // Retrieve the report
         Report report = api.GetReport(reportKey);

         // Uncomment the following line of code line if you do not want any filters 
         // If commented out, then the filters set in CP are applied.
         // report.ClearFilters(); 
         
         // Set filters (optional)
         report.SetFilterText("Filter_FirstName", TextOperators.Contains, "the");
         report.SetFilterText("Filter_LastName", TextOperators.Contains, "the");


         // Uncomment the following line of code line if you do not want any options
         // If commented out, then the options set in CP are used
         // report.ClearOptions(); 

         // Set options (optional)


         // Gather the report's data
         //
         // Note: Some reports only return the data needed to produce the report. If you want
         // to return all data, then change GetReportData(false) to GetReportData(true)
         DataSet ds =  report.GetReportData(false); 

		 // Close the database 
         api.CloseDatabase();
         return ds;
      }
      static void Main(string[] args) {
      }
   }
}

Edited by user Friday, January 3, 2020 5:57:06 PM(UTC)  | Reason: Not specified

tony  
#2 Posted : Friday, January 3, 2020 6:11:12 PM(UTC)
tony

Rank: Advanced Member

Groups: Registered
Joined: 2/28/2018(UTC)
Posts: 65
United States
Location: Pennsylvani mostly

Was thanked: 9 time(s) in 9 post(s)
DataAccessAPI is in CenterPointDataBrowser.DLL.

I'm not sure how Mono C# handles references to DLLs but in Visual Studio, your project would need a Reference to that DLL. If the reference didn't exist, that would cause a compile-time error. Are you getting a compile-time error?

I found this: https://www.mono-project.com/community/help/

If it's a run-time error, then it is probably because CenterPointDataBrowser.DLL has its own set of dependencies - it requires several CenterPoint DLLs which in turn may depend on still other CenterPoint DLLs. If this is the problem, then running your code in a folder that contains the CenterPoint DLLs would probably solve the problem.

thanks 1 user thanked tony for this useful post.
payrollproject on 1/3/2020(UTC)
payrollproject  
#3 Posted : Friday, January 3, 2020 7:05:51 PM(UTC)
payrollproject

Rank: Member

Groups: Registered
Joined: 1/3/2020(UTC)
Posts: 11

Thanks: 2 times
Thanks, this is resolved. Yes, it was a compile time error.

Here's how I got it to compile. In Mono, there is an /r: option which takes a path to the DLLs. I got it to compile by supplying the /r: option with CenterPointDataBrowser.DLL

In order to figure out how to set up my project to reference all your DLLs, I will consult the Mono Project documentation you linked.
tony  
#4 Posted : Friday, January 3, 2020 7:17:03 PM(UTC)
tony

Rank: Advanced Member

Groups: Registered
Joined: 2/28/2018(UTC)
Posts: 65
United States
Location: Pennsylvani mostly

Was thanked: 9 time(s) in 9 post(s)
Thanks for the update!

You really should only have to set up that one reference.

If you get run-time errors, that is because the browser DLL can't find the other CenterPoint DLLs that CenterPointDataBrowser.DLL depends on. I don't believe that you can resolve that problem with the /r: option. If you run into run-time problems, run your hello.exe in the same folder as the CenterPoint DLLs - this would be the ReflectedDLLs folder underneath the main CenterPoint folder.
payrollproject  
#5 Posted : Friday, January 3, 2020 7:38:10 PM(UTC)
payrollproject

Rank: Member

Groups: Registered
Joined: 1/3/2020(UTC)
Posts: 11

Thanks: 2 times
I did end up getting runtime errors, as you predicted.

To simplify things, I switched to Microsoft C# (csc). I also put the program in the ReflectedDLLs folder. Still got runtime errors. Here are the commands I typed in command prompt. Compiles fine, but doesn't run. Command prompt is running in Administrator mode.

Code:

C:\Program Files (x86)\Red Wing Software\CenterPoint\ReflectedDLLs>csc --version

Microsoft (R) Visual C# Compiler version 3.4.0-beta4-19569-03 (82f2e254)
Copyright (C) Microsoft Corporation. All rights reserved.

error CS2007: Unrecognized option: '--version'
warning CS2008: No source files specified.
error CS1562: Outputs without source must have the /out option specified

C:\Program Files (x86)\Red Wing Software\CenterPoint\ReflectedDLLs>csc /r:Center
pointDataBrowser.DLL hello.cs
Microsoft (R) Visual C# Compiler version 3.4.0-beta4-19569-03 (82f2e254)
Copyright (C) Microsoft Corporation. All rights reserved.


C:\Program Files (x86)\Red Wing Software\CenterPoint\ReflectedDLLs>hello.exe

Unhandled Exception: System.BadImageFormatException: Could not load file or asse
mbly 'CenterPointDataBrowser, Version=14.10.6.0, Culture=neutral, PublicKeyToken
=null' or one of its dependencies. An attempt was made to load a program with an
 incorrect format.
   at CenterPointDataBrowser.ReportDataExample.GetReportData()
   at CenterPointDataBrowser.ReportDataExample.Main(String[] args)

C:\Program Files (x86)\Red Wing Software\CenterPoint\ReflectedDLLs>

Edited by user Friday, January 3, 2020 7:39:38 PM(UTC)  | Reason: Not specified

payrollproject  
#6 Posted : Friday, January 3, 2020 8:46:05 PM(UTC)
payrollproject

Rank: Member

Groups: Registered
Joined: 1/3/2020(UTC)
Posts: 11

Thanks: 2 times
Update: I got the code to run.

The runtime error was resolved when I realized that CenterPoint is using 32-bit. I had to set up my environment to compile to x86, instead of "Any CPU" or x64. Then, the code ran.
Nibblez4everybody  
#7 Posted : Tuesday, December 7, 2021 6:48:32 AM(UTC)
Nibblez4everybody

Rank: Newbie

Groups: Registered
Joined: 10/5/2021(UTC)
Posts: 9
United States
Location: Bakersfield

Hello, I am wondering how you went to set up your environment to compile to x86, instead of "Any CPU". I am having the same error when I try to run my code from the command line.
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.