I see a strange issue(Most likely my code is not complete), can some one take a look and help me out why following code runs fine but no changes are happening. Whn I go and take a look at identity tab, nothing has changed. OS is windows 2008 server r2
COMAdminCatalog cc = new COMAdminCatalog);
COMAdminCatalogCollection ccc = (COMAdminCatalogCollection)cc.GetCollection("Applications");
ccc.Populate();
foreach(COMAdminCatalogObject cap in ccc){
if(cap.Name.ToString() == config.Application){
//cap.set_value("Authentication",COMAdminAuthenticationLevelOptions.COMAdminAuthenticationConnect)//I have changed all options here but no effect
cap.set_Value("Identity", config.user);
cap.set_Value("Password", config.password);
ccc.SaveChanges();//breakpoint here
}
}
It turned out that ccc.SaveChanges() returns an error code =1 does any one know what it means?
MS documentation says error codes returned are in hex values such as 0x800401 etc(just made up)
I did this myself (learn something new every day!) and this is my results, hopefully we can figure out your problem:
I created a new COM+ server Application and copied your code (with minor changes so it finds my app, because I don't know what config is in your example :)
From debugging up to ccc.SaveChanges() - this line should throw exceptions if something went wrong. In my case, I got an UnauthorizedAccessException - I fixed that by running my code in Visual Studio as administrator
Once I did that, ccc.SaveChanges() worked - I went to my Identity tab and it updated the user and password correctly (if you enter a wrong username or password in the code, it also throws an exception I believe).
The return type you are getting, the 1, isn't an error code I believe. Because that's what mine returns and it is working fine.
You could try surrounding your ccc.SaveChanges() in a try catch and see if any exceptions are thrown.
I hope this helps.
First of all THANK YOU ryrich for taking time to help me out. What it turned out to be the reason for which my changes were not shown is as dumb as it possibly can be. It is consistent on 3 machines where I tested it. Here is what I noticed.
Every time I run the code above, it did work as there were no errors, but I could not see the changes in Component Services Console, the messed up part is that I HAD to close the Component Services console completely, then restart it and only then I could see the changes.
This behavior was consistent on all three systems where I tested it.
1: WinXP sp3
2: Win 7 SP1
3: Win 2008 Server R2
I am explaining this so just in case some one else might see this STUPID behavior...
Related
I am new to Visual Studio / Test Complete / C#. I have written a Test Complete test in C#, but when I try to run it it says "Cannot Create Test Complete Object". The only question so far that I have found does not apply to me. Even if it did, I did, as it suggested, run the program as admin but the same problem.
This is nowhere near enough information for you to go on, so let me continue.
My Test Complete test extends a class "AbstractTestCase" that we got from our team. This is the base class that has been used for years, so I am sure it is OK. I made a simple test, just to try to click an object. I have no idea whether the values are correct, but for now it does not matter, as my test is throwing an exception in the "Before()" method, so it has not gotten there yet.
The exception is being thrown at this method, which I believe is Smart Bear method, so I cannot debug into it, and it shows no line number:
Connect.RunTest(GetTestName(), "Generic", Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + #"\Automation\TcFramwork\TcFramwork.pjs");
The values are as follows:
GetTestName() = "RepriceTest"
Path.GetDirectoryName... = "C:\VS_Projects\ErepricerSolution\ErepriceClassLibrary\bin\Debug\Automation\TcFramwork\TcFramwork.pjs"
I do have a file C:\VS_Projects\ErepricerSolution\ErepriceClassLibrary\bin\Debug\Automation\TcFramwork\TcFramwork.pjs
which looks like this (along with a "Generic" subdirectory). Please see attached file. To attach it I had to convert it to an XML file.
The only difference is this. Because my Desktop started crashing, I was one of the first (and only so far) people to get a laptop. Others will be getting themn as time goes on. The laptop has Windows 10, while everyone else has Windows 7. The Laptop has Test Complete 12. The laptop had Visual Studio 2015, but due to compiler incompatibilities with Smart Bear Connetc, I had to have Visual Studio 12 installed, which I am using.
So others are using Windows 7, Visual Studio 12 and Test complete 12, while I am using Windows 10, Visual Studio 12 and Test Complete 12.
I do see somewhat of a backtrace from this Connect.RunTest(), so maybe someone can figure out what's going on. Please see attached file trace.png.
I am also attaching a copy of my test class. (And again I have no idea whether the Connect statement is right, but it never gets that far)
I can't upload files but I did share them on my google drive.
PJS file: https://drive.google.com/open?id=1FZ2__0smKTKZ8d6mqVxIO8gP4r_A-92y
Test Class: https://drive.google.com/open?id=1ixitvZ45M11Va1eDv-7Vv9Lz9WHh-k41
Stack Trace: https://drive.google.com/open?id=1C57iNacRnrmmGkE4Lx9mvetobPiJN3G4
PSJ File: https://drive.google.com/open?id=1FZ2__0smKTKZ8d6mqVxIO8gP4r_A-92y
I have this single line of code in a Word VSTO add-in project which used to work but suddenly doesn't anymore:
Microsoft.Office.Interop.Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;
Before it just returned the Document object as it was supposed to, and I could read from and manipulate it without issue. But now it throws a System.Runtime.InteropServices.COMException exception. "Word has encountered a problem." Very helpful. The exception contains an HRESULT of 0x800A13E9, which hasn't helped me so far either. Out of memory or something? Idk.
The new behavior seems to have started around New Year's Eve (not sure since I wasn't using the add-in for the past couple of weeks), and it started while the add-in was installed, i.e. nothing in the code was changed, recompiled or reinstalled to make it happen. I've since rebuilt the project, thinking maybe a certificate had expired or something, but the error still occurs.
It's maybe worth noting that I can still access other properties of the Application instance. For instance, this line does not throw an exception:
int numDocuments = Globals.ThisAddIn.Application.Documents.Count;
But then when I iterate over the Documents collection with foreach, it just skips over the loop as if the count was zero.
The only thing I can think of is that an update to Office (365) has broken something related to VSTO. But where do I even begin debugging this?
Okay, so I tried creating a new Word VSTO add-in, changing none of the default project properties, but adding a single ribbon with a single button and the following method:
private void button1_Click(object sender, RibbonControlEventArgs e)
{
try
{
var x = Globals.ThisAddIn.Application.ActiveDocument;
}
catch (Exception ex)
{
;
}
}
It throws exactly the same exception on getting the ActiveDocument property. I did however notice that there are two more exceptions thrown when loading the add-in, and they're also thrown when loading the original add-in (that used to work fine):
Exception thrown: 'System.Deployment.Application.DeploymentException' in System.Deployment.dll
Exception thrown: 'System.Security.Cryptography.CryptographicException' in Microsoft.VisualStudio.Tools.Applications.Hosting.dll
They don't prevent the add-in from loading and running, but maybe they're related to the problem anyway? I don't know if they were also thrown last year before the problem appeared.
I do however have a couple of Excel add-ins that still run fine with the same version of VSTO, Visual Studio and Office, and they don't throw the above two exceptions when loading. So the issue seems to be specific to Word.
And now I tried rolling back to Office 365 version 1810, the October release, which definitely worked before, so I think it's probably not a problem introduced by an Office update. It's something else. Probably.
Not that it really helps me much, but at least I've ruled that out. Probably.
The problem seems to be triggered by the Windows 10 October 2018 Update (or November). The affected customers had special Windows regional settings: Example: "English (Switzerland)".
Solution:
Change the Windows regional settings format to "English (UK)" or "English (US)"
The VBA Editor also no longer worked correctly for the affected customers (without installed add-ins). The error "Word has encountered a problem" (Visual Basic Error 5097) occurred directly during opening. The same error that occurs in C# for Application.ActiveDocument
Well, rolling back to the previous version of Windows 10 (1803 in my case, apparently) fixed the issue, and I can't reproduce it at the moment, so I'll mark this as solved for now.
While I still have no clue what exactly the deal was, I did at least learn in my research that clicking the "Check for updates" button in Windows 10 instantly makes you a beta tester for Microsoft. As in, they deliberately put you on the unstable update train, without any sort of notice, let alone a warning that you're about to install updates that they don't consider ready for release yet.
Anyway, I hope they got some good telemetry from my many, many hours of trying everything I could think of, so that maybe the issue is fixed by the time the update is forced on me. If not, I guess I'll be back to ask the same question again. At least I'll know where to start looking for the cause.
From my experience :
when i was closing the Active Document at that time i was refreshing Ribbon Menu according to the active document.
If the closing document was the Last document i wasn't able to read any property of
Microsoft.Office.Interop.Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;
and i was facing the same issue like you.
whenever i close any document i check
if(Globals.ThisAddIn.Application.Documents.Count = 1){
LastActiveDocument = true;
}
And when i refresh the Ribbion Menu i check
if(!LastActiveDocument){
// then only read any property of Active document
}
Microsoft has fixed the issue
Microsoft has released an Office update to fix this issue.
With Office Version 1902 (Build 11328.20158) the issue is fixed on my side.
Im getting this error while indexing documents as an attachment. What can be the reason for this type of error. And why is it behaving differently when I run on server and when I run from visual studio.
More details about the problem is mentioned here.
Please have a look at the below link.
https://discuss.elastic.co/t/systemmemoryoutofexception-thrown-while-indexing-files-as-an-attachment/50916
TIA
I am not confident on where the actual error is ocurring. You need to determine if the error is in .net (on the client side) or in elastic? Both Visual Studio and elasticsearch will get to a point where they break without enough memory (or allocated memory) on the host machine.
If it is in elastic (check the logs - or run in console mode) - increase the heap space.
If it is on the client, try forcing your application in to 64 bit mode.
I am using the Office Integration Pack
After following instruction correctly I am still not able to get the Excel to Import working
My Visual Studio Lightswitch 2011 application is configured to host on IIS Server and use's Easy Shell (so its the default Shell provided by MS).
So far I have tried is calling the
OfficeIntegration.Excel.Import(
this.States,
#"C:\Users\Mr_Mia_Gie\My Documents\ExcelSheet.xls",
"Sheet1",
"A1:C3");
on _Execute event of a button (the button does not live on the Shell Command Bar)
The exception I get back is "Object variable or With block variable not set."
Any solution or suggestion will be highly appreciated
Cheers
I agree with Nevyn (& I'd vote up his answer, but it's embedded in the question as an edit so I can't).
As Nevyn has pointed out, there are really only three objects in that particular line of code that can be causing a null exception:
the OfficeIntegration object
the OfficeIntegration.Excel object
or, the this.States collection (unlikely though)
As was also pointed out for you, it's most likely that one of those objects isn't correctly initialised. You need to check what the value of those three objects are by putting a break point on that line & checking what their values actually are at that point.
You could also put a guard clause in your code (just above that line):
if (OfficeIntegration == null) || (OfficeIntegration.Excel == null) return;
It won't neccesarily "fix" the problem, but it will stop the null exception from occuring (but this shouldn't be a problem in an Execute method). But it's good programing practice to put a guard clause any time you're referencing an object whose value could be null.
Failing that, the only other advice any of us can give you is to post a question in the questions section of the gallery page, where you downloaded the extension from. The autor of the extension should be able to help you.
Is this a web application, if so I dont think it supports it. It requires an extenstion. I dug up an article for you, try it out:
http://blogs.msdn.com/b/lightswitch/archive/2011/04/13/how-to-import-data-from-excel.aspx
The office integration Pack is for Visual Studio LightSwitch windows application and does work for application that are hosted on IIS hence the below code throws exception
OfficeIntegration.Excel.Import(
this.States,
#"C:\Users\Mr_Mia_Gie\My Documents\ExcelSheet.xls",
"Sheet1",
"A1:C3");
The link show that the extension does not support LS WebBrowser application http://officeintegration.codeplex.com/discussions/374585
Also the extension Import data from Excel does work for IIS hosted LS application that runs in webbrowser
I am coding a c# command line application (WIN7, 64bit) that should write many lines to the command line.
I cooked the problem down to the following code:
int lineno;
for (lineno = 0; lineno < 100000; lineno++) {
Console.WriteLine(">" + lineno);
}
I can't understand why the apllication dies after 39404 lines:
...
>39401
>39402
>39403
>39404
"Console Application has stopped working."
Please let me know if you have any ideas what went wrong here.
Thank you & best regards, Dirk.
I doubt your question. Because my program works fine and shows till 99999 under MS Visual Studio 2008.
EDIT : After Dirk commented on Davido's answer, with Console.WriteLine(">>>" + lineno); the output prints many 36251 times. But that's incorrect. With ">>>" also, program accurately works.
Here's image for same.
I couldn't reproduce the problem--it seems the problem is environment.
Does it always fail at 39404? Does it fail after a certain period of time? How do you launch it? Have you tried launching it from command line? Are you sure this is all code that you have? Have you tried building it with different configurations?
Answering these questions, you might find what causes the problem.
Edit: the oddest thing I see about it is this message:
"Console Application has stopped working."
It's obviously not system or framework message.
Please post complete code because it looks like you're doing something wrong.
Works fine on my system. (Windows 7, VS 2010).
What Operating System and Framework version are you using?
Try changing your application target to compile for x86. Sometimes this solves strange issues I have with different projects.
Edit:
Dirk, try making a NEW project and putting your code in a blank console project. See if that changes how it outputs. I suspect that doing this will change the number of lines you are able to write. If so, then there is a problem with some of your other code that you haven't posted. Just something you might want to consider.