- Create a new .net class library project for the wrapper
- Declare the class as "ComVisible":
using System.Runtime.InteropServices;
[ComVisible( true )] public class ClassName - Generate the Keyfile:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\sn.exe -k "keyfile.snk" - Set the project property to sign the library using the generated keyfile
- Generate the Registry entry with the path to the library .dll as the "codebase":
regasm.exe %TRGDIR%\LibName.dll /codebase
Specify also the /tlb option if the library is to be imported by the C++ #import directive - Check the registry has the ProgId: LibName.ClassName and refers to the CLSID which has the "codebase" path to the LibName.dll
Friday, April 8, 2011
COM to .NET
How to make a .NET class library be accessible as a COM object?
Friday, April 1, 2011
min-height in IE
All the standard browsers have the min-height CSS property, but IE has it only in the strict !DOCTYPE mode (which is a nightmare) and it does not work properly anyway.
As a workaround, we can do the following
1) Specify the min-height which is ignored by IE
2) Specify the "hight" for IE only.
How to make the other browsers to ignore the "height"?
There are at least two solutions found:
1) Make a weird selector path, like:
* html .dd_h { height: 18px; }
(.dd_h is the class name for the object which need the min-height)
2) Add the style property with an underscore ahead:
.dd_h { min-height: 18px; _height: 18px; }
In some reason IE processes such property as usual, and of course it's ignored by proper browsers.
Source:
http://www.cssplay.co.uk/boxes/minheight.html
http://sandgroper14.wordpress.com/2007/05/24/css-min-height-issue-solved/
As a workaround, we can do the following
1) Specify the min-height which is ignored by IE
2) Specify the "hight" for IE only.
How to make the other browsers to ignore the "height"?
There are at least two solutions found:
1) Make a weird selector path, like:
* html .dd_h { height: 18px; }
(.dd_h is the class name for the object which need the min-height)
2) Add the style property with an underscore ahead:
.dd_h { min-height: 18px; _height: 18px; }
In some reason IE processes such property as usual, and of course it's ignored by proper browsers.
Source:
http://www.cssplay.co.uk/boxes/minheight.html
http://sandgroper14.wordpress.com/2007/05/24/css-min-height-issue-solved/
Tuesday, March 22, 2011
Android versions we have
Android developer console has a new statistic feature.
In that we can see the current Android's version distribution:
Android 2.2 - 57.8%
Android 2.1 - 29.0%
Android 1.6 - 6.8%
Android 1.5 - 4.9%
Android 2.3.3 - 0.6%
Gingerbread already available for 5 month (from when it was first introduced), and still has a tiny share.
Will the other makers start to install it on their devices some day or it will never happen due the enormous Gingerbread ugliness?
In that we can see the current Android's version distribution:
Android 2.2 - 57.8%
Android 2.1 - 29.0%
Android 1.6 - 6.8%
Android 1.5 - 4.9%
Android 2.3.3 - 0.6%
Gingerbread already available for 5 month (from when it was first introduced), and still has a tiny share.
Will the other makers start to install it on their devices some day or it will never happen due the enormous Gingerbread ugliness?
Saturday, March 12, 2011
GMail advanced IMAP
GMail was quite annoying placing all the old emails to the "All Mail" folder.
I don't care if they want to archive them but I do care when my IMAP client downloads all the oldies each time and keeps the huge copy on the local storage.
Praise all gods, that can be fixed. As described in the following article:
http://www.macobserver.com/tmo/answers/how_to_setup_gmail_imap_and_mail.app1/
In short, just go to the settings, then to the "Labs", and enable the "Advanced IMAP controls". Then go to the "Labels" and uncheck the "All Mail - Show in IMAP" checkbox.
That's it. The mail client won't see that folder anymore!
I don't care if they want to archive them but I do care when my IMAP client downloads all the oldies each time and keeps the huge copy on the local storage.
Praise all gods, that can be fixed. As described in the following article:
http://www.macobserver.com/tmo/answers/how_to_setup_gmail_imap_and_mail.app1/
In short, just go to the settings, then to the "Labs", and enable the "Advanced IMAP controls". Then go to the "Labels" and uncheck the "All Mail - Show in IMAP" checkbox.
That's it. The mail client won't see that folder anymore!
Tuesday, March 1, 2011
Excel needs the Desktop
To make Excel automation works from IIS:
Excel uses the "Desktop" folder for something.
Even though IIS execution right personalized to an user specified in the application pool advanced settings, Excel still executes in the system environment, so, we need to create the desktop folder for it:
C:\Windows\System32\config\systemprofile\Desktop
read more at:
http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required
Also, give proper rights to the folder "C:\Windows\System32\config\systemprofile\" and to the Excel's DCOM properties (go "Administrative Tools/Component Services") to the user which executes Excel
To run the DCOM config:
When the office has the same bits as the OS:
DCOMCNFG.exe
When 32bit office on 64bit OS:
Note! Even if the caller 32bit and the Excel is 64 bit, it should work fine, since the Excel object is called via DCOM.
Also! The Excel need a valid accessible printer to produce documents.
Make sure the default printer has enough permissions which allow the IIS user to print on it.
Excel uses the "Desktop" folder for something.
Even though IIS execution right personalized to an user specified in the application pool advanced settings, Excel still executes in the system environment, so, we need to create the desktop folder for it:
C:\Windows\System32\config\systemprofile\Desktop
read more at:
http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91?prof=required
Also, give proper rights to the folder "C:\Windows\System32\config\systemprofile\" and to the Excel's DCOM properties (go "Administrative Tools/Component Services") to the user which executes Excel
To run the DCOM config:
When the office has the same bits as the OS:
DCOMCNFG.exe
When 32bit office on 64bit OS:
mmc comexp.msc /32
Note! Even if the caller 32bit and the Excel is 64 bit, it should work fine, since the Excel object is called via DCOM.
Also! The Excel need a valid accessible printer to produce documents.
Make sure the default printer has enough permissions which allow the IIS user to print on it.
Saturday, January 22, 2011
about code optimization
You can not reduce the entropy. I redesigned a big chunk of code, shrank the file size by 200 lines (from 1400 to 1200), and the resulted .class file remained the same size.
Tuesday, January 18, 2011
If you need to send a BLOB to a HTTP server using vbscript, then you need
pass to the send() method the stream. But if it's multipart/form-data format, aside of the binary data the POST body should contain also boundaries and other metadata.
So, we have to store in a stream text data then binary then again some text.
It can be done by using the ADODB.Stream object.
It`s type (binary or text) can be converted dynamically, during the writing.
But! Before the setting the new type, the position has to be set to 0.
It can be then restored, after the type conversion to value taken from the stream.Size property.
pass to the send() method the stream. But if it's multipart/form-data format, aside of the binary data the POST body should contain also boundaries and other metadata.
So, we have to store in a stream text data then binary then again some text.
It can be done by using the ADODB.Stream object.
It`s type (binary or text) can be converted dynamically, during the writing.
But! Before the setting the new type, the position has to be set to 0.
It can be then restored, after the type conversion to value taken from the stream.Size property.
option explicit
dim stream, file_loader, file_name, bnd
set stream = CreateObject("ADODB.Stream")
set file_loader = CreateObject("ADODB.Stream")
const adTypeBinary = 1
const adTypeText = 2
stream.Open
stream.Type = adTypeText
stream.CharSet = "iso-8859-1"
bnd = "boundary"file_name = "test.png"
stream.WriteText( "--" & bnd & vbCrLf & _
"Content-Disposition: form-data; name=""the_file""; filename=""" & file_name & """" & vbCrLf & _
"Content-Type: application/octet-stream" & vbCrLf & vbCrLf )
stream.Position = 0
stream.Type = adTypeBinary
stream.Position = stream.Size
WScript.Echo "Position before file loading: " & stream.Position
file_loader.Open
file_loader.Type = adTypeBinary
file_loader.LoadFromFile( file_name )
file_loader.CopyTo stream
stream.Position = 0
stream.Type = adTypeText
stream.CharSet = "iso-8859-1"
stream.Position = stream.Size
WScript.Echo "Position after file loading: " & stream.Position
stream.WriteText( vbCrLf & "--" & bnd & "--" & vbCrLf )
stream.Position = 0
stream.Type = adTypeBinary
dim http_req
set http_req = CreateObject("WinHTTP.WinHTTPRequest.5.1")
'WinHTTP.WinHTTPRequest.5.1 better than Msxml2.XMLHTTP because it lets you override the http headers
call http_req.SetProxy( 2, "127.0.0.1:8888" ) ' for Fiddler proxy
call http_req.open( "POST", "http://127.0.0.1/", false )
call http_req.send( stream )
Subscribe to:
Posts (Atom)