PropertyAccessor Outlook - properties

PropertyAccessor opa = outlookitem.PropertyAccessor;
opa.SetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/Id", "100");
var val = opa.GetProperty("http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/Id");
When i try this on my own calendar (outlookitem) created in my calendar it works fine. But when i add a colleagues calendar to my Outlook at try it there i get the following exception, when calling GetProperty.
Any ideas?
An exception of type 'System.Runtime.InteropServices.COMException' occurred in *** but was not handled in user code
Additional information: The property "http://schemas.microsoft.com/mapi/string/{FFF40745-D92F-4C11-9E14-92701F001EB3}/Id" is unknown or cannot be found.

had to save the item before a accessing the property. Not it works. Thanks

Related

Entity Framework: .Add & .SaveChanges() is not adding entity to database

When I am adding an entry
var objectEntity = new ObjectStaging();
objectEntity .CreatedBy = ClaimsPrincipal.Current.Identity.Name;
objectEntity .ModifiedBy = ClaimsPrincipal.Current.Identity.Name;
objectEntity .Set(ObjectInfo);
database.ObjectStaging.Add(objectEntity);
database.SaveChanges();
For some reason, my objectEntity is not being added to my database given the following code. When using the debugger, it moves through database.ObjectStaging.Add(objectEntity); but does not continue after calling SaveChanges(). Is there a way to know why it is failing to add the entry to the database?
Exception Thrown:
Exception thrown:
'System.Data.Entity.Validation.DbEntityValidationException' in
VCC.BrokerPortal.DAO.dll Validation failed for one or more entities.
See 'EntityValidationErrors' property for more details.
Is there a way to know what specifically did not validate?
Also, I tested the state of the entity using the following lines of code,
database.ObjectStaging.Add(objectEntity);
var state= brokerPortalDB.Entry(objectEntity).State;
state currently shows the value of 'added'.
Thank you!
I ended up looking into the exception thrown and it appears it was related to one of the properties not having proper validation. In this instance I had a [MaxLength] attribute assigned to a field and I was trying to add a value longer than that length allowed.

Errors running Google API calendar example for vb.net

When I try to run this example in VBExpress 2010, I get the following intellisense errors.
scopes.Add(CalendarService.Scopes.Calendar.GetStringValue())
This line generates:
Error 7 Overload resolution failed because no accessible
'GetStringValue' is most specific for these arguments:
Extension method 'Public Function GetStringValue() As String' defined in 'Google.Apis.Util.Utilities': Not most specific.
Extension method 'Public Function GetStringValue() As String' defined in 'Google.Apis.Util.Utilities': Not most specific.
Additionally, these two lines each generate a "not defined" error.
Dim credentials As FullClientCredentials = promptingClientCredentials.EnsureFullClientCredentials()
Dim initializer As New BaseClientService.Initializer()
Error 9 Type 'BaseClientService.Initializer' is not defined.
Error 8 Type 'FullClientCredentials' is not defined.
Finally, this line:
Dim state As IAuthorizationState = AuthorizationMgr.GetCachedRefreshToken(STORAGE, KEY)
generates the error:
Error 15 'AuthorizationMgr' is not declared. It may be inaccessible
due to its protection level.
As to the first error, both google.apis.silverlight.google.apis.util.utilities and google.apis.google.apis.util.utilities has a GetStringValue(system.enum) as String method.
Any ideas about any of these errors?
UPDATE: Excluding Silverlight dll seems to resolve first error ("Not most specific")
We just published a new sample using VB.NET and OAuth2.
It works in VS Professional 2012. Take a look - http://samples.google-api-dotnet-client.googlecode.com/hg/Calendar.VB.ConsoleApp/README.html

Using COM object from PowerBuilder - error 36: name not found accessing external object

I'm trying to access a third-party COM server from within Powerbuilder. I can instantiate the object but whenever I try to call a method or a property on the object I get error 36: "name not found accessing external object".
OLEObject PNSession
PNSession = CREATE OLEObject
ll_status = PNSession.ConnectToNewObject("PNSrv9.PNSession")
if ll_status = 0 then
// Set the session printer
try
PNSession.SetSessionPrinter('TIFF Image Printer 9.0', 1, g_pfapp.null_string, False)
catch (oleruntimeerror lole_error2)
messagebox('Set Error', lole_error2.description)
end try
// Turn job tracking on
PNSession.TrackingOn = True
end if
The ConnectToNewObject call succeeds and I see the COM server in my Task Manager, but subsequent calls fail. The above looks correct based on all the COM automation code samples for Word, Excel that I looked at.
The COM server is a C++ ATL COM Server, not a .NET COM object if that makes any difference.
Does anyone have an idea why this isn't working or what I am missing?
Thanks.
You probably don't have the parameter types correct. Looking at SetSessionPrinter, I would try passing 0 for PortsPreCreated. For PortBaseName try a string initialized to "" and also try 0.
Similarly, try PNSession.TrackingOn = 0.

SPWeb.GetListItem COMException on first call - second is ok

I'm trying to use SPWeb.GetListItem() to get an item by a known URL (MSDN).
So basically I'm doing the following:
using (SPSite spSite = SPContext.Current.Site)
{
using (SPWeb spWeb = spSite.RootWeb)
{
SPListItem spListItem = spWeb.GetListItem
("/sites/testSite/Lists/testList/Folder/Subfolder");
}
}
in case you are wondering, I'm trying to get the folder "Subfolder" to do stuff with it.
The problem is that the first time I call this, I get a COMExpeption:
Cannot complete this action.
Please try
again.<nativehr>0x80004005</nativehr><nativestack></nativestack>
Description: An unhandled exception
occurred during the execution of the
current web request. Please review the
stack trace for more information about
the error and where it originated in
the code.
Exception Details:
System.Runtime.InteropServices.COMException:
Cannot complete this action.
There are some reports about the COMException happening because you need to use the full relative site URL, so instead of /Lists/testList/Folder/SubFolder, you need to use /sites/testSite/Lists/... - I'm doing just that. I also tried using the absolute URL (http://sharepoint/sites/...). The problem remains: I get the COMException when trying to get the spListItem for the first time.
When I try to run the code again after the Exception, the SPListItem is received just fine. Also all subsequent calls work - only the first one fails.
AmI doing some initializing wrong or something like that?
Perhaps try SPWeb.GetFolder() instead... but again it depends on what exactly you want to do with the Folder. Seems strange though that you're using a method used for getting list items on a Folder.
http://msdn.microsoft.com/en-us/library/ms461547.aspx
Try to instantiate the web where the list item is located - _uiserWeb.
I tryed Site.RootWeb.GetListItem(item_url) - it gave me null first time after code redeployment and was fine second time.
_item = _userWeb.GetListItem(item_url)

Unity Container Type Registration Quirk

I'm trying to automatically register all reports in a unity container.
All reports implement IReport and also have a Report() attribute which defines the title, description and unique key (so I can read these without instantiating a concrete class).
So...
I get the report types like this
Public Shared Function GetClassesWhichimplementInterface(Of T)() As IEnumerable(Of Type)
Dim InterfaceType = GetType(T)
Dim Types As IEnumerable(Of Type)
Types = Reflection.Assembly.GetCallingAssembly.GetTypes()
Return Types.Where(Function(x) InterfaceType.IsAssignableFrom(x))
End Function
And register them like this:
Public Sub RegisterReports()
Dim ReportTypes = ReflectionHelper.GetClassesWhichimplementInterface(Of IReport)()
For Each ReportType In ReportTypes
''Previously I was reading the report attribute here and using the defined unique key. I've stopped using this code to remove possible problems while debugging.
Container.RegisterType(GetType(IReport), ReportType, ReportType.Name)
Next
End Sub
There are types being returned by the call to GetClassesWhichimplementInterface() and the Container.RegisterType() call is made without errors. If I call Container.Resolve(of Interfaces.IReport) immediately after the register call, I get the following exception:
Resolution of the dependency failed, type = "MyProject.Interfaces.IReport", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, MyProject.Interfaces.IReport, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving MyProject.Interfaces.IReport,(none)
Can anyone tell me why the container isn't preserving the registration?
The registration is in the container. The thing is that you are calling resolve without passing a named registration as a parameter.
As all your registrations were performed using the following code:
Container.RegisterType(GetType(IReport), ReportType, ReportType.Name)
Then all of them have a name. You must provide the name along with the type to be able to resolve the dependency from the container.
The error you are getting is because there is no type mapping registered without a name.