ZoomFit error when using Eyeshot 2021 on Windows Server - c#

Good afternoon,
I am trying to use Eyeshot in a .NET Framework Web Application to create a Bitmap image. The steps of the process in my code are the following: I generate all the necessary Entities and then I add them to a Model control that is not visible in the Web Application; once all Entities are added, I use the ZoomFit() method to zoom to the desired Entities and then I use the RenderToBitmap() method to create the Bitmap image.
The issue regards the ZoomFit() method: when executed, it gives the following error message:
"Control's handle must be created first".
The portion of code regarding the creation of the Model control is the following:
Model model1 = new Model();
model1.InitializeViewports();
model1.Size = new Size(500, 300);
model1.CreateControl();
model1.Layers.Add("Grid");
model1.Layers["Grid"].LineWeight = 0.3f;
model1.Layers["Grid"].Color = Color.LightGray;
model1.Layers.Add("Gauges");
model1.Layers["Gauges"].LineWeight = 1.5f;
// List of entities for correct zooming
IList<Entity> Grid = new List<Entity>();
IList<Entity> Gauges = new List<Entity>();
// List of strings containing the paths to the dxf files on the server
List<string> drawingsFilePaths = (List<string>)Session["drawingsFilePaths"];
// List of images
List<Bitmap> drawings = new List<Bitmap>();
foreach (string path in drawingsFilePaths)
{
// Clearing the entities every time I change the file
model1.Entities.Clear();
// Creating the viewport starting from the dxf files
ReadAutodesk read = new ReadAutodesk(path);
read.DoWork();
foreach (Entity en in read.Entities)
{
if (en.LayerName == "Grid")
{
Grid.Add(en);
}
else if (en.LayerName == "Gauges")
{
Gauges.Add(en);
}
model1.Entities.Add(en);
}
model1.ActiveViewport.OriginSymbol.Visible = false;
model1.ActiveViewport.ViewCubeIcon.Visible = false;
model1.ActiveViewport.ToolBar.Visible = false;
model1.ActiveViewport.SetView(viewType.Right);
model1.ZoomFit(Gauges, false);
Bitmap tmp = model1.RenderToBitmap(1);
drawings.Add(tmp);
However, this issue is faced ONLY when publishing the Web Application on a remote Server (Windows Server 2012); in fact, when I publish it using my own personal computer (Windows 10) as a server, everything works perfectly.
I already checked the presence of all the Eyeshot DLLs in the pubblished Web Application, and the settings of IIS on my PC and on the Server are the same. Could it be an issue related to some missing references that are implicitly called by Eyeshot DLLs and are not present on Windows Server? What do you think is the problem?
Kind regards,
Giacomo Balestrieri

This is a licensing issue. Eyeshot Trial version cannot be copied on other machines. The same problem would occur if you copy your app to a different Win10 machine.

Related

CentralFileCommunicationException When Using OpenAndActivateDocument

We receive Revit model from other companies, so those models are not central models or local models, or have access to their central model location. I created, what I thought, was a simple routine to open the received model, detached, so I can save it as a new central model on our network.
ModelPath path = ModelPathUtils.ConvertUserVisiblePathToModelPath(#"C:\Temp\received model.rvt");
OpenOptions opts = new OpenOptions();
opts.Audit = true;
opts.AllowOpeningLocalByWrongUser = true;
opts.DetachFromCentralOption = DetachFromCentralOption.DetachAndPreserveWorksets;
opts.SetOpenWorksetsConfiguration(new WorksetConfiguration(WorksetConfigurationOption.OpenAllWorksets));
UIDocument uidoc = this.OpenAndActivateDocument(path, opts, false);
The code works as expected in all but ONE case: when the received file has it's a Workset Configuration of "Specify...". No matter what WorksetConfiguration I use to try and open the Document, I get the exception.
When I look at the journal file, where the open fails I have this message:
Observable::getWorksetConfigForLoading 'Specify' = askUser
I've tried using, WorksetConfigurationOption.OpenAllWorksets, WorksetConfigurationOption.CloseAllWorksets and WorksetConfigurationOption.OpenLastViewed. I'm in Revit 2016, 2018 and 2020.
You could try the three levels of Detecting and Handling Dialogues and Failures. Maybe the Failure API will help, or the JtClicker Windows API hook approach.

VlcLibDirectory not found

I'm using VS 2017 and coding in C#. I installed the 4 Vlc libraries to play videos in a Windows Form Application. I put a Vlc control in the form. And then, in the code, I wrote:
vlcControl1.SetMedia(curFolder + #"\media\1.mp4");
vlcControl1.Play();
When I run it, I get a "VlcLibDirectory not found". What I need to do? I see that I can set that directory through visual controls, in the VlcControl1 properties, but what is that folder?
I'm sorry this is late...
You got the first part, getting the packages in Visual Studio, now you need the libraries for it.
Download this: https://github.com/ZeBobo5/Vlc.DotNet/tree/master
Put the lib directory somewhere the application can find it, and set that VlcLibDirectory equal to a new DirectoryInfo(path to dir).
I did it like this:
var libDirectory = new DirectoryInfo(Path.Combine(".", "libvlc", IntPtr.Size == 4 ? "x86" : "x64"));
vlcControl1 = new Vlc.DotNet.Forms.VlcControl();
vlcControl1.VlcLibDirectory = libDirectory;
The library that it needs to be loaded is libvlc.dll that is found in the folder where is installed the VLC software.
I visited practically every Google result page for this, almost lost hope, but this worked for me in the end:
1) Created an object in my FormsApp file:
VlcControl vlcControl1 = new VlcControl();
2) Instantiated it in the constructor:
VlcControl vlcControl1 = new VlcControl();
3) In my FormsApp_Load() added the following lines:
vlcControl1.BeginInit();
vlcControl1.VlcLibDirectory = new DirectoryInfo(_exeFolder + #"\libvlc\win-x86"); //Make sure your dir is correct
vlcControl1.VlcMediaplayerOptions = new[] { "-vv"}; //not sure what this does
vlcControl1.EndInit();
YourControlContainer.Controls.Add(vlcControl1); //Add the control to your container
vlcControl1.Dock = DockStyle.Fill; //Optional
this.vlcControl1.Click += new EventHandler(vlcControl1_Click); //Optional - added a click event .Play()
Hope this helps someone.
I've also experienced this problem.
I just look into the properties of the VlcControl on the Form and change the VlcLibDirectory item under the Media Player category by browsing to the directory which the "libvlc.dll" located.
(in my application C:\Users\MCOT\source\repos\WindowsApp3\packages\VideoLAN.LibVLC.Windows.3.0.6\build\x86)
#Thanin's answer is what I needed, ... here is a code snippet to where the library should be installed.
//InitializeComponent();
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(
"SOFTWARE\\VideoLAN\\VLC",
RegistryKeyPermissionCheck.ReadSubTree,
RegistryRights.QueryValues))
{
_Vlc.SourceProvider.CreatePlayer(
new DirectoryInfo(rk.GetValue("InstallDir") as string),
new string[] { });
}

SharePoint Event Reciever Works On One Machine/computer/user

So we have created an updated version of a WSP for SharePoint 2010 due to our migration/update from 2007 to 2010.
The WSP is a event handler/reciever for ItemAdded() and we have it working as intended. Issue is that the operation seems to only work for one computer/machine and no others.
When the Item is Added to a list the WSP creates a Folder in Shared Documents library, creates a wiki page, then updates the new List Item with links to the Shared Doc and Wiki.
When triggered by Machine #1 and User #1 all operations work, when Machine #2(M2) and user #2(U2) or M3 and U3 non of the tasks take place when a new Item is created.
User #2 can log in on M1 and create a new item and all operations work. But if U1 uses M2 or M3 to create an item the events don't trigger. Machine #1 is able to trigger the event as many times as they want but no other computer is able to.
If you were able to follow is it something with the code or some sort of cache setting on the local machine or the SP server, or something else? Any help is appreciated.
Update: All machines are on the same network. Non of the machines are the server but various personal laptops. Development was done on a separate machine. All are accessing via the same URL. All users have same access. This is on our test site currently which would be switched to being production once migration/upgrade takes place.
Before current .WSP deployment we noticed the same issue but it was reverse, Machine #2 did all the updates but Machine #1 and #3 couldn't. Only thing we can think of was that those machines were the first to trigger the event after deployment.
I'm Not doing the .WSP install but our IT guy is(won't let us have access :/ but I understand) but below is the install commands he is running.
Add-SPSolution -LiteralPath "OurPath/ourFile.wsp"
Install-SPSolution -Identity ourIdentity -WebApplication http://myhost.com/ -GACDeployment
Below is the main part of the code
public class CreateWikiAndFolder : Microsoft.SharePoint.SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
//this.DisableEventFiring();
base.EventFiringEnabled = false;
string sUrlOfWikiPage = string.Empty;
string sUrlOfNewFolder = string.Empty;
string sSubsiteRUL = string.Empty;
string sCurrentItemTitle = properties.ListItem["Title"].ToString();
string sWikiListName = "TR Wikis";
string sDocLibName = "Shared Documents";
string sTRListID = "TR Status";
if (sTRListID.ToUpper().Equals(properties.ListTitle.ToString().ToUpper()))
{
//Create the Folder
sUrlOfNewFolder = CreateFolder(properties.ListItem.Web, sDocLibName, sCurrentItemTitle);
//Create the Wiki
string ItemDispFormUrl = String.Concat(properties.ListItem.Web.Url, "/", properties.ListItem.ParentList.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url, "?ID=", properties.ListItem.ID.ToString());
sUrlOfWikiPage = CreateWiki(properties.ListItem.Web, sWikiListName, sCurrentItemTitle, ItemDispFormUrl, sUrlOfNewFolder);
//Update the current TR Item
SPWeb myWeb = properties.ListItem.Web;
myWeb.AllowUnsafeUpdates = true;
SPListItem myListItem = properties.ListItem;
SPFieldUrlValue shareFolderURLValue = new SPFieldUrlValue();
shareFolderURLValue.Description = "Shared Folder";
shareFolderURLValue.Url = sUrlOfNewFolder ;
myListItem["SharedFolder"] = shareFolderURLValue;
myListItem.Update();
myWeb.AllowUnsafeUpdates = false;
}
base.EventFiringEnabled = true;
}
catch (Exception e)
{
//Currently throwing nothing
}
}
}
It could be a hardcoded path/url, however there is not enough information to identify the problem, I would be glad to update my answer with a more detailed theory if you provide more details or if you share some of your code.
Figured out the issue. I didn't include them with the above file code. But we were StreamWriting to a text file on the server to help us with debugging. Issue was with that, When user 1 was logged on their machine and the log files didn't exist, they would get generated. Now no other users then had read/write access to those files and so it errored out at our debug files for anyone else. But that Windows user could run it as much as they wanted as they were the owner of the file :/

MonoDroid evaluation System.UnauthorizedAccessException in Directory.CreateDirectory()

Scenario:
Start MonoDevelop
new Android Application
Replace button click delegate with
string fullPath = "/data/misc.mvvmcross.customermanagement/files/_Caches/Pictures.MvvmCross/";
if (System.IO.Directory.Exists(fullPath))
{
button.Text = "exists";
}
else
{
button.Text = "not found";
Directory.CreateDirectory(fullPath);
}
run and click the button.
Directory.CreateDirectory will fail with
System.UnauthorizedAccessException
Have tried creating a new emulator image with different API levels, but problem is still here
Any thoughts anyone?
Ok, Have created new Android Emulator image and used that.
Everything now works.
Solution:
Create a new android emulator image for the API level you want (don't forget Google API support)
I'm wondering if this is caused by some kind of assembly/package naming issue.
I've tested this code:
string fullPath = Path.Combine(FilesDir.Path, "_Caches2/Pictures.MvvmCross/2/");
if (System.IO.Directory.Exists(fullPath))
{
button.Text = "exists";
}
else
{
button.Text = fullPath;
Directory.CreateDirectory(fullPath);
}
...and it works fine in a 2.3.3 emulator.
The data folder pattern is: /data/ * package name * /files/
And it is correct (I think) for one package not to be able to access the data of another.
So I'm wondering if somehow your package names are wrong - check the manifest tab and the manifest.xml file for your application?

WMEncoder Throws COMException (0x80004005) Unspecified Error

So I'm running this code
public static void ConvertToWma(string inFile, string outFile, string profileName)
{
// Create a WMEncoder object.
WMEncoder encoder = new WMEncoder();
ManualResetEvent stopped = new ManualResetEvent(false);
encoder.OnStateChange += delegate(WMENC_ENCODER_STATE enumState)
{
if (enumState == WMENC_ENCODER_STATE.WMENC_ENCODER_STOPPED)
stopped.Set();
};
// Retrieve the source group collection.
IWMEncSourceGroupCollection srcGrpColl = encoder.SourceGroupCollection;
// Add a source group to the collection.
IWMEncSourceGroup srcGrp = srcGrpColl.Add("SG_1");
// Add an audio source to the source group.
IWMEncSource srcAud = srcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
srcAud.SetInput(inFile, "", "");
// Specify a file object in which to save encoded content.
IWMEncFile file = encoder.File;
file.LocalFileName = outFile;
// Choose a profile from the collection.
IWMEncProfileCollection proColl = encoder.ProfileCollection;
proColl.ProfileDirectory = AssemblyInformation.GetExecutingAssemblyDirectory();
proColl.Refresh();
IWMEncProfile pro;
for (int i = 0; i < proColl.Count; i++)
{
pro = proColl.Item(i);
if (pro.Name == profileName)
{
srcGrp.set_Profile(pro);
break;
}
}
// Start the encoding process.
// Wait until the encoding process stops before exiting the application.
encoder.SynchronizeOperation = false;
encoder.PrepareToEncode(true);
encoder.Start();
stopped.WaitOne();
}
And I get a COMException (0x80004005) when encoder.PrepareToEncode gets executed.
Some notes:
1) The process is spawned by an ASP.NET web service so it runs as NETWORK SERVICE
2) inFile and outFile are absolute local paths and their extensions are correct, in addition inFile definitely exists (this has been a source of problems in the past)
3) The program works when I run it as myself but doesn't work in the ASP.NET context.
This says to me its a security permission issue so in addition I've granted Full Control to the directory containing the program AND the directories containing the audio files to NETWORK SERVICE. So I really don't have any idea what more I can do on the security front. Any help?
Running WM Encoder SDK based app in windows service is not supported. It uses hidden windows for various reasons, and there isn't a desktop window in service. DRM would certainly fail with no user profile. Besides, even when you make your service talk to WME instance on a user's desktop, Microsoft only supports 4 concurrent requests per machine because the global lock in WME (I know, not pretty programming, but WME is old). For more scalable solutions, consider Windows Media Format SDK.
You may want to move your WM Encoder based app to Expression Encoder SDK as WM Encoder's support is ending.

Categories

Resources