I'm struggling to get my application out of break mode, here is what happened:
This was my code and everything worked ok:
Engine btEngine = new Engine();
btEngine.Start();
LabelFormatDocument SerialPlate = btEngine.Documents.Open(#"C:\Afrisoft\Labels\ItemLabel_General.btw");
LabelFormatDocument BoxLabel = btEngine.Documents.Open(#"C:\Afrisoft\Labels\BoxLabel_General.btw");
SerialPlate.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
BoxLabel.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
Result SerialPlateResult = SerialPlate.Print();
Result BoxLabelResult = BoxLabel.Print();
btEngine.Stop();
Then I changed it to the following as the documentation suggested:
using (Engine btEngine = new Engine(true))
{
LabelFormatDocument SerialPlate = btEngine.Documents.Open(#"C:\Afrisoft\Labels\ItemLabel_General.btw");
LabelFormatDocument BoxLabel = btEngine.Documents.Open(#"C:\Afrisoft\Labels\BoxLabel_General.btw");
SerialPlate.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
BoxLabel.DatabaseConnections.QueryPrompts["JobNumber"].Value = textBox1.Text.Trim();
Result SerialPlateResult = SerialPlate.Print();
Result BoxLabelResult = BoxLabel.Print();
I inserted a break point at:
using (Engine btEngine = new Engine(true))
and then when I took the break point away to test that part as well the app keeps crashing at that point. I've re-added the reference, changed the code back to the when it did work, but nothing fixes it.
Please help.
Looks like the library broke, reinstalling it fixed the issue
Related
I have a Visual Studio extension that we use internally for a project and one of the things it needs to be able to do is post tickets to VSTS. Previously we were using onsite TFS and making a connection to post tickets was as simple as:
var vssCreds = new VssCredentials(true);
projectCollection = new TfsTeamProjectCollection(url, vssCreds);
workItems = projectCollection.GetService<WorkItemStore>();
project = workItems.Projects["My Project"];
defaultType = project.WorkItemTypes["Bug"];
//...
var newItem = new WorkItem(defaultType)
{
Title = title
};
newItem.Fields["Assigned To"].Value = assignTo;
newItem.Fields["Repro Steps"].Value = repoSteps;
var validationResult = newItem.Validate();
newItem.Save();
And this worked fine. But after upgrading to VSTS I'm having a hard time getting the credentials part to work. I changed this line:
projectCollection = new TfsTeamProjectCollection(url, vssCreds);
To this:
projectCollection = new TfsTeamProjectCollection(url, new VssClientCredentials());
And this worked fine for me. But when I share it with other people on my team it didn't work at first and then started working a little later. I am guessing that interacting with VSTS caused their credentials to be loaded so that it then worked. But I have at least one person who just seems to be completely unable to make it work.
So what's the correct way to get it to use the VSTS credentials (that should already exist in VS)?
I see this overload for VssClientCredentials (https://msdn.microsoft.com/en-us/library/dn228355(v=vs.120).aspx):
public VssClientCredentials(
IVssCredentialPrompt credentialPrompt
)
Which I suspect might be useful, but I can't seem to find out if there's a built in implementation of IVssCredentialPrompt somewhere or, if not, how to implement it.
Remove the related key from
Computer\HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp, then authentication again.
You also can specify other Kind (vssApp by default) and Namespace (VisualStudio by default) by using this code:
var c = new VssClientCredentials();
c.Storage = new VssClientCredentialStorage(storageKind: "VssApp2", storageNamespace: "VisualStudio");
projectCollection = new TfsTeamProjectCollection(url, c);
For reasons that are entirely unclear and from this answer to an entirely different question: https://stackoverflow.com/a/40256731/1250301
It seems that spawning a new thread causes a login prompt to appear if needed and fix all the problems. So if I do this:
Task.Run(() =>
{
var url = new Uri(_tfsUrl);
var cred = new VssClientCredentials();
projectCollection = new TfsTeamProjectCollection(url, cred);
workItems = projectCollection.GetService<WorkItemStore>();
}).Wait();
project = workItems.Projects["Job Posting Data"];
defaultType = project.WorkItemTypes["Bug"];
taskType = project.WorkItemTypes["Task"];
Then it works. I have no idea why it works, or why this is necessary (at first I thought maybe it was a problem with not being in the UI thread so I'd tried Application.Current.Dispatcher.Invoke which did not work) but it seems to have fixed the problem.
I try to create a new EPT (project server 2013) using C# CSOM library.
But It has following error occurred.
"PJClientCallableException: EnterpriseProjectTypeInvalidCreatePDPUid"
Couple of article tell to change the "IsCreate=true". But it does not success for me. Here is the code what I have done.
public void CreateEnterpriseProjectType(Guid eptGuid, string eptName, string eptDescription)
{
ProjectContext pwaContext = new ProjectContext(this.PWA_URL);
EnterpriseProjectTypeCreationInformation eptData = new EnterpriseProjectTypeCreationInformation();
eptData.Id = eptGuid;
eptData.Name = eptName;
eptData.Description = eptDescription;
eptData.IsDefault = false;
eptData.IsManaged = true;
eptData.WorkspaceTemplateName = "PROJECTSITE#0";
eptData.ProjectPlanTemplateId = Guid.Empty;
eptData.WorkflowAssociationId = Guid.Empty;
eptData.Order = 4;
List<ProjectDetailPageCreationInformation> projectDetailPages = new
List<ProjectDetailPageCreationInformation>() {
new ProjectDetailPageCreationInformation() {
Id = pwaContext.ProjectDetailPages[1].Id, IsCreate = true }
};
eptData.ProjectDetailPages = projectDetailPages;
pwaContext.Load(pwaContext.EnterpriseProjectTypes);
pwaContext.ExecuteQuery();
EnterpriseProjectType newEpt = pwaContext.EnterpriseProjectTypes.Add(eptData);
pwaContext.EnterpriseProjectTypes.Update();
pwaContext.ExecuteQuery();
}
Can anyone explain the issue or provide the working code part.
I would like to suggest the following:
Define an enterprise project type:
string basicEpt = "Enterprise Project"; // Basic enterprise project type.
int timeoutSeconds = 10; // The maximum wait time for a queue job, in seconds.
And then, when you create the new project, work like this:
ProjectCreationInformation newProj = new ProjectCreationInformation();
newProj.Id = Guid.NewGuid();
newProj.Name = "Project Name";
newProj.Description = "Test creating a project with CSOM";
newProj.Start = DateTime.Today.Date;
// Setting the EPT GUID is optional. If no EPT is specified, Project Server
// uses the default EPT.
newProj.EnterpriseProjectTypeId = GetEptUid(basicEpt);
PublishedProject newPublishedProj = projContext.Projects.Add(newProj);
QueueJob qJob = projContext.Projects.Update();
// Calling Load and ExecuteQuery for the queue job is optional.
// projContext.Load(qJob);
// projContext.ExecuteQuery();
JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);
When the last line of that piece of code ends, the project must be created and published in order to define tasks or whatever.
I don't know what is happening to your code, seems great.
Hope it helps to you,
I am working with FileNet API and I can create document's attachments correctly.
First, I create the document in the CE and later i connect the new pid in the PE.
Here it is the core of my code.
//update mode
parameter.Modified = true;
//Attchment creation
attachment = new peWS.Attachment();
attachment.LibraryType = peWS.LibraryTypeEnum.LIBRARY_TYPE_CONTENT_ENGINE;
attachment.Type = peWS.AttachmentTypeEnum.ATTACHMENT_TYPE_DOCUMENT;
attachment.Id = version_series;
attachment.Version = null;
attachment.Library = obj;
attachment.Name = System.IO.Path.GetFileName(path);
attachment.Description = description;
//value updates
list_values = parameter.Values.ToList();
val.ItemElementName = peWS.ItemChoiceType.attachmentField;
val.Item = attachment;
list_values.Add(val);
parameter.Values = list_values.ToArray();
//save
peWS.UpdateStepRequest updStepRequest = new peWS.UpdateStepRequest();
peWS.UpdateFlagEnum updFlagEnum = peWS.UpdateFlagEnum.UPDATE_SAVE_UNLOCK;
updStepRequest.stepElement = stepElement;
updStepRequest.updateFlag = updFlagEnum;
peWSClient.updateStep(updStepRequest);
It works correctly and if I loop the attachments I can manage them (show, update, delete).
The problem is in the front end tool Navigator: i see the added attachments but the first one is always unreadable.
I can't even click on it because it is enabled by Navigator itself.
It does not seem a code problem, but maybe i am missing some tricky parameter. Could someone help?
I found a solution of the problem that i posted.
It was a Navigator's bug of the version that i was using.
If I update Navigator at the 2.0.2. version it will work just fine.
I am trying to do highlighting on the search results. Here is the relevant part of my code.
QueryScorer scorer = new QueryScorer(q);
Lucene.Net.Search.Highlight.IFormatter formatter = new SimpleHTMLFormatter("<b>", "</b>");
Lucene.Net.Search.Highlight.Highlighter highlighter = new Highlighter(formatter, scorer);
highlighter.TextFragmenter = new SimpleFragmenter(800);
Lucene.Net.Util.Version vers = new Lucene.Net.Util.Version();
vers = Lucene.Net.Util.Version.LUCENE_30;
TokenStream stream = new StandardAnalyzer(vers).TokenStream(string.Empty, new StringReader(text));
string s = string.Empty;
try
{
s = highlighter.GetBestFragments(stream, text, 10, "...");
}
Here, GetBestFragments method throws a System.MissingMethodException.
I have tried to replace the original Lucene.net dll with Lucene.Net.Contrib but this time, I dont know what I should write instead of TokenStream. It doesnt exist in Lucene.Net.Contrib.* dlls.
I am working on existing code and I need to find out how I can rewrite TokenStream class and GetBestFragments method.
Thanx
The problem was something about deployment, that the new compatible Lucene.dll was replaced by the incompatible Sitecore7 dll.
So, if both lucene.net and lucene.net.contrib dll are referenced, it should work.
Not directly the solution to my question, but this source is worth mentioning again. (About lucene.dll versions) : http://laubplusco.net/sitecore-7-lucen-3-0-highlighted-results/
My goal is to connect to a WMS Service and display a layer on my application's map using ESRI's ArcObject API for .NET.
Here is the part of my code I am struggling with:
...
String url = "some value";
String layerTitle = "another value";
...
PropertySet props = new PropertySet();
props.SetProperty("URL", url);
WMSConnectionName connectionName = new WMSConnectionName();
connectionName.ConnectionProperties = props;
WMSMapLayer mapLayer = new WMSMapLayer();
(mapLayer as IDataLayer).Connect(connectionName as IName);
IWMSGroupLayer groupLayer = (IWMSGroupLayer)mapLayer;
IWMSServiceDescription serviceDescription = groupLayer.WMSServiceDescription;
IWMSLayerDescription layerDescription = serviceDescription.get_LayerDescription(0);
groupLayer.CreateWMSLayer(layerDescription);
groupLayer.get_Layer(0).Visible = true;
ILayer layer = (ILayer)groupLayer;
layer.Name = "WxOverlays " + layerTitle;
layer.Visible = true;
At run time I encounter:
System.Runtime.InteropServices.COMException (0x8000FFFF): The supplied
command does not exist in the command pool at
ESRI.ArcGIS.GISClient.IWMSServiceDescription.get_LayerDescription(Int32
index)
A google search revealed that some similar methods in the ArcObject API throw the same exception because they are not supported in C#. Has anyone encountered this before? Anyone see a way around it? Unfortunately, I am stuck using C#, so using Java or something that may have better support from ESRI is out of the question.