I'm trying to generate lookup tables in SharePoint and taking reference from a sample project. Here is the code snippet I'm referring to:
using Microsoft.SharePoint.Client;
using Microsoft.ProjectServer.Client;
using System.Security;
using System.Configuration;
namespace PWA_CSOM
{
public partial class FinalLogic_Second : System.Windows.Forms.Form
{
#region veriables
private static ProjectContext projContext;
string pwaPath = "";
string userId = "";
string userPassword = "";
}
}
I have created a new project and created a variable to type ProjectContext, however I'm not able to find the reference for it. I have tried everywhere but no luck:
using Microsoft.ProjectServer.Client; //Missing Reference
namespace LookupTable
{
public static class Infrastructure
{
#region Properties
public ProjectContext project;
#endregion
}
}
I tried Local Assembly Reference but no luck -
Also tried the Nuget Reference -
Is there something missed from my end? Any help is appreciated.
Install SharePoint Online CSOM package in Package Manager Console in Visual studio.
Install-Package Microsoft.SharePointOnline.CSOM -Version 16.1.7723.1200
https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM
If you have already installed Project Server you can do this.
As mentioned Here ,
You can reference to this library again by just going into this path and select the dll file.
%ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.ProjectServer.Client.dll
Related
I have an NUnit test project dedicated for unit testing which has a Target Framework of .Net Core 2.1. This test project has references of two other Projects one of which is a Windows Form based application and the other is a Class Library based application for database interactions. Both of these projects has a target framework of .Net Framework 4.6.1
I am writing a test for testing a method of the Class Library based application to test the output of the method. But it's showing the following error,
'System.IO.FileNotFoundException : Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.'
I have tried the following fixes and none of them worked.
Removing the project references and adding them again
Changing build platform target from AnyCPU to X86 and x64
Adding dependant assemblies tag inside a .config file. (Interesting things is .NET Core 2.1 doesn't provide with a .config file)
This is the test class (Test_DataClasses.cs),
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Data.SQLite;
using SharedDataClasses;
using MantechAutomationControl;
using System.IO;
using System.Reflection;
namespace MAC_Testing
{
[TestFixture]
class Test_DataClasses
{
#region Tests
[Test]
public void t_m_initializeDatabase()
{
//Assign
string v_dbLocation = Path.Combine("M:\\For_Jabed\\MAC\\MAC\\MantechAutomationControl\\bin\\Debug\\", "DB.sqlite");
//Act
DataClasses_v2.m_initializeDatabase();
//Assert
Assert.That(new FileInfo(v_dbLocation), Does.Exist);
}
#endregion
}
}
And this is the method the above test is trying to validate,
public static class DataClasses_v2
{
#region Variables
#endregion
#region Methods
public static void m_initializeDatabase()
{
string v_executableLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string v_dbLocation = Path.Combine(v_executableLocation, "DB.sqlite");
if (!File.Exists(v_dbLocation))
{
DialogResult o_createDBFileDialogBox = MessageBox.Show("Could not find the database in the expected location:\n" + v_dbLocation + "\n\nWould you like to create a new blank database file?", "Warning", MessageBoxButtons.YesNo);
if (o_createDBFileDialogBox == DialogResult.Yes)
{
SQLiteConnection.CreateFile(v_dbLocation);
using (SQLiteConnection o_dbConnection = new SQLiteConnection(#"DataSource=" + v_dbLocation + ";Version=3;"))
{
o_dbConnection.Open();
}
}
else
return;
}
}
I don't really understand whats going on here. Although point to be noted I actually was working towards to use Nunit Form dll to work with Forms (DialogBox) as the method to be tested had a DialogBox to work with.
In the test project there is another class and the tests written inside those class works fine for the Same target 'Class Library' based project to validate a different function.
Hopefully someone will be able to explain whats going on here.
Try to compile C# code with method RepositoryType() which is described here
http://sparxsystems.com/enterprise_architect_user_guide/13.0/automation/repository3.html
And I got this error
Error CS1061 'Repository' does not contain a definition for 'RepositoryType' and no extension method 'RepositoryType' accepting a first argument of type 'Repository' could be found (are you missing a using directive or an assembly reference?)
I tried to cleaning/rebuiling all stuff, but its not working. Also, during runtime call looks fine - returns string.
What could help?
UPD:
Usings and assignation
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using EA;
using MSScriptControl;
public class SparxEaDocGenScriptRunner
{
private MSScriptControl.ScriptControl _msScriptControl;
private EA.Repository _repository;
private string _language;
private string _databaseType;
private Regex _eaLanguageDeterm;
private Regex _getExtFromName;
private IDictionary<string, string> _languageExts;
/// <summary>
/// Add-in logger accessor.
/// </summary>
private ApplicationLogger _logger;
public SparxEaDocGenScriptRunner(Repository repository, ApplicationLogger logger)
{
_repository = repository;
_logger = logger;
var connectionString = _repository.ConnectionString;
var type = _repository.RepositoryType();
}
//...
}
And its injected all way from this part of code in, lets say, Main.cs:
public void EA_MenuClick(EA.Repository Repo, string Location, string MenuName, string ItemName)
{
switch (ItemName)
{
case MENU_DOC_GEN:
#region Logging Statement
Logger.Write(new LogEntry
{
Severity = TraceEventType.Information,
Message = "Loading Document Generator",
Categories = new[] { ApplicationConstants.DocumentGeneratorLogCategory }
});
#endregion
DocumentGenerator docgen = new DocumentGenerator(Repo);
docgen.ShowDialog();
break;
case MENU_ABOUT:
new AboutBox().Show();
break;
}
}
UPD2:
My EA.Interop.dll version:
I wrote to support, referenced on my qusetion here, and got my answer :) It really helped. And I was too careless, again.
Hi Danil,
Thank you for your enquiry.
It's possible that you are referencing an older version of the
EA.Interop.dll file which did not yet contain this function. We could
see in your screenshot that you are referencing this Interop DLL from
somewhere under "C:\Users\temp1...".
Please note that the version number of the EA.Interop.dll file doesn't
get updated between EA versions, it is generally more useful to look
at the created/modified timestamp on the file. What are the timestamps
on the Interop DLL file you are referencing and the one in your
current EA install directory? (default: C:\Program Files (x86)\Sparx
Systems\EA)
I would suggest either changing your reference to point directly to
the DLL from your current EA installation, or copy the current version
from your EA install directory and overwrite the location where your
dll is being referenced from.
Best regards,
Aaron Bell
Sparx Systems Pty Ltd
support#sparxsystems.com
http://www.sparxsystems.com
Well, so I reinstalled Sparx EA, copied .dll from installation folder and it worked!
I'm building an WPF C# Application with an embedded SQLite Database.
But when I debug it I always get an exception of type 'SQLite.SQLiteException'.
using System.Collections.Generic;
using System.Linq;
using SQLite;
using System.Collections;
namespace SheepMaster
{
class SheepDao : IEnumerable
{
private List<Sheep> sheeps { get; set; }
private SQLiteConnection con = new SQLiteConnection("sheeps.db");
public SheepDao()
{
con.CreateTable<Sheep>();
sheeps = con.Table<Sheep>().ToList();
}
public IEnumerator GetEnumerator()
{
return sheeps.GetEnumerator();
}
public void add(Sheep value)
{
sheeps.Add(value);
}
}
}
When I try to install sqlite from nuget I am getting the following error message:
Could not install package 'sqlite.redist 3.8.4.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
and when I manually install it I get this message:
A reference to path could not be added...
System.Data.SQLite
I installed it trought nuget but it didn't change anything.
Either download and install sqlite3.dll from: http://sqlite.org/download.html
or Find on nuget package SQLite v3.13.
i'm using microsoft visual C# 2010 express to write a form program to read and write to an access database.
i created a class that is designed to read/write to the database file, saved it under a namespace and created a dll from it.
it is set as ".net Framework 4"
in my main program i added the reference to the dll file but when i try to add it to the code with
using Database;
it won't work even that the Database is in the reference of the namespace.
am i doing something wrong? or is there another way to use the commands from Database in my main program other then copying it to it?
// update //
solved
added public to all database public and DataBase db = new DataBase();
DATABASE.cs is use it for dll
using System;
using System.Collections.Generic;
using System.Data.OleDb;
namespace Database
{
public class DataBase
{
public DataBase()
{
}
public void ItemInsert(string name,string creator,string publishing,string itemType,string genere, string year)
the main program
using System;
using System.Windows.Forms;
using Database;
namespace library
{
public partial class newItemForm : Form
{
private void btnConfirmNewItemClick(object sender, EventArgs e)
{
DataBase db = new DataBase(); //this solved it
db.ItemInsert(txtItemNameType.Text, txtEditorType.Text, txtCreatorType.Text, comboBoxType.Text, txtGenereType.Text, txtYearType.Text);
}
}
}
You also need to Add a Reference to said assembly in your current project. The using statement brings a referenced assembly into scope...
right click you project in visual studio, select add refrence then choose Browse tab, then find the poject folder and get in bin -> debug and then you will see the dll choose it. visual studio will add it to your refrences, now you need to add a using on top of the pages you want it like this:
using mydllName;
if you didnt find your dll:
Load the librery project agian and right click in visual studio and press Build it will generate the dll.
You must add a reference to the assembly you created. The point of creating an Assembly is not that you don't have to "copy it" to another project, but rather that you don't have to duplicate code.
I'm developing in Visual Studio 2010 and I've just downloaded and installed Script# 0.6.2 for VS 2010. I'm trying to follow the clock example in the Read Me pdf but can't get it to compile.
I've created a new Script# Class Library project inside my solution called Clock, renamed the .cs file to ClockBehaviour and added the following code as per the example:
using System;
using System.DHTML;
using ScriptFX;
using ScriptFX.UI;
namespace Clock {
public class ClockBehavior : Behavior {
private int _intervalCookie;
public ClockBehavior(DOMElement domElement, string id) : base(domElement, id) {
_intervalCookie = Window.SetInterval(OnTimer, 1000);
}
public override void Dispose() {
if (_intervalCookie != 0) {
Window.ClearInterval(_intervalCookie);
} base.Dispose();
} private void OnTimer() { DateTime dateTime = new DateTime(); DOMElement.InnerHTML = dateTime.Format("T"); }
}
}
When I try and compile the project I get errors saying that the System.DHMTL, ScriptFX and ScriptFX.UI namespaces could not be found (and some others, but I guess by fixing these errors the others will fall out).
It feels like I'm not referencing the correct projects/dlls. In the References for the project I have mscorlib and Script.Web. I've tried using the object browser find the classes (such as Behavior) in other namespaces but with no luck. I've added all of the .dlls from the ScriptSharp folder in Program Files but the namespaces still can't be found.
Any help would be very much appreciated,
Thanks,
Hugh
the sample docs are a bit out of date - look at the phot sample in the samples download : http://projects.nikhilk.net/Content/Projects/ScriptSharp/Sample.zip
See http://projects.nikhilk.net/ScriptSharp/Conceptual-What
You need to reference ssfx.Core.dll which should be installed with Script#
(Alternatively, see pp 23-24 of the pdf you linked...)